do("INSERT INTO 'players' ($keys) VALUES ($placeholders);", array_values($data)); return App::$db->lastInsertID(); } public static function validateCredentials(string $identifier, string $password, bool $fetch = false): int|false { // get the player from their username or email $player = App::$db->do("SELECT " . ($fetch ? '*' : 'id, password') . " FROM players WHERE LOWER(username) = :i OR LOWER(email) = :i LIMIT 1;", ['i' => strtolower($identifier)]); if ($player == false) return false; $player = $player->fetch(); // check password, return the player data if good if (password_verify($password, $player['password'])) { unset($player['password']); return $fetch ? $player : $player['id']; } return false; } }