error->code . ": " . $response->error->error . "\n"; $maintainer[0] = $response->error->code; $maintainer[1] = $response->error->error; } else { $pdo = null; try { $pdo = new PDO("sqlite:" . './slork.sqlite'); } catch (PDOException $e) { // handle the exception here } $query = "INSERT OR REPLACE INTO maintainer (maintainer, api) VALUES (?, ?);"; $stmt = $pdo->prepare( $query ); $stmt->execute( [$response->player_id, $api] ); $query = "INSERT OR REPLACE INTO player (maintainer, player, property, value) VALUES (?, ?, ?, ?);"; $stmt = $pdo->prepare( $query ); $stmt->execute( [$response->player_id, $response->player_id, 'name', $response->name] ); // $pdo->commit(); $maintainer[0] = $response->player_id; $maintainer[1] = $response->name; } return $maintainer; } function get_maintainer( $id ) { /** * @param string $id Maintainer's XID * @return array XID and name of maintainer */ $pdo = null; try { $pdo = new PDO("sqlite:" . './slork.sqlite'); } catch (PDOException $e) { // handle the exception here } $query = "SELECT value FROM player WHERE maintainer = ? AND player = ? AND property = 'name';"; $stmt = $pdo->prepare( $query ); $stmt->execute( [$id, $id] ); $maintainer = [0, '?']; $row = $stmt->fetchAll(); $maintainer[0] = $id; $maintainer[1] = $row['value']; return $maintainer; } function delete_player( $player ) { $pdo = null; try { $pdo = new PDO("sqlite:" . './slork.sqlite'); } catch (PDOException $e) { // handle the exception here } $maintainer = $_REQUEST['m']; $query = "DELETE FROM player WHERE player = ? AND maintainer = ?;"; $stmt = $pdo->prepare( $query ); $stmt->execute( [$player, $maintainer] ); $maintainer = get_maintainer( $maintainer ); if ( $player == $maintainer ) { // Poof $query = "DELETE FROM maintainer WHERE maintainer = ?"; $stmt = $pdo->prepare( $query ); $stmt->execute( [$maintainer] ); $maintainer = [0, '?']; } return $maintainer; }