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 username = :i OR email = :i LIMIT 1;", ['i' => $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; } }