add games

This commit is contained in:
2025-12-02 14:55:55 +01:00
parent 975b704553
commit 46ea9d10d3
10 changed files with 634 additions and 76 deletions
+7 -6
View File
@@ -165,7 +165,7 @@ function saveLocalization(
}
// =====================================================
// GAMES IN MULTIMEDIAFLUTTER (Tabelle games)
// GAMES IN MULTIMEDIAFLUTTER (Tabelle game)
// =====================================================
function saveGameStatus(
@@ -178,7 +178,7 @@ function saveGameStatus(
$pdo = getDb();
$sql = '
INSERT INTO games (igdb_id, name, original_name, status, note)
INSERT INTO game (igdb_id, name, original_name, status, note)
VALUES (:igdb_id, :name, :original_name, :status, :note)
ON DUPLICATE KEY UPDATE
name = VALUES(name),
@@ -197,7 +197,7 @@ function saveGameStatus(
':note' => $note,
]);
$stmt = $pdo->prepare('SELECT * FROM games WHERE igdb_id = :id LIMIT 1');
$stmt = $pdo->prepare('SELECT * FROM game WHERE igdb_id = :id LIMIT 1');
$stmt->execute([':id' => $igdbId]);
return $stmt->fetch() ?: [];
}
@@ -205,7 +205,7 @@ function saveGameStatus(
function getGameByIgdbId(int $igdbId): ?array
{
$pdo = getDb();
$stmt = $pdo->prepare('SELECT * FROM games WHERE igdb_id = :id LIMIT 1');
$stmt = $pdo->prepare('SELECT * FROM game WHERE igdb_id = :id LIMIT 1');
$stmt->execute([':id' => $igdbId]);
return $stmt->fetch() ?: null;
}
@@ -493,12 +493,13 @@ switch ($action) {
$offset = ($page - 1) * $limit;
$safeQuery = str_replace('"', '\\"', $query);
$body = sprintf(
'fields id,name,summary,first_release_date,cover.image_id; ' .
'limit %d; offset %d; search "%s";',
$limit,
$offset,
addslashes($query)
$safeQuery
);
$results = igdbRequest('/games', $body);
@@ -509,7 +510,7 @@ switch ($action) {
? igdbImageUrl($g['cover']['image_id'], 't_cover_big')
: null;
// eigener Status aus games
// eigener Status aus game-Tabelle
$localGame = getGameByIgdbId($g['id']);
$g['my_status'] = $localGame['status'] ?? null;