Actualiser api.php
This commit is contained in:
@@ -579,7 +579,21 @@ case 'get_config_keys':
|
|||||||
]);
|
]);
|
||||||
$imported++;
|
$imported++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// CORRECTION : Initialisation des variables manquantes
|
||||||
|
$stmtCritiques = $pdo->prepare("INSERT INTO critiques (id, title, year, director, poster, rating, review, streaming)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
|
ON DUPLICATE KEY UPDATE title=VALUES(title), year=VALUES(year), director=VALUES(director),
|
||||||
|
poster=VALUES(poster), rating=VALUES(rating), review=VALUES(review), streaming=VALUES(streaming)");
|
||||||
|
$tmdbApiKey = getTmdbApiKey($pdo);
|
||||||
|
|
||||||
|
foreach ($items as $rowData) {
|
||||||
|
$title = $rowData['Title'] ?? $rowData['title'] ?? '';
|
||||||
|
if (empty($title)) continue;
|
||||||
|
|
||||||
|
$year = $rowData['Year'] ?? $rowData['year'] ?? '';
|
||||||
|
$id = makeStableId('critique', $title, $year);
|
||||||
|
|
||||||
$ratingRaw = $rowData['Rating'] ?? $rowData['rating'] ?? '';
|
$ratingRaw = $rowData['Rating'] ?? $rowData['rating'] ?? '';
|
||||||
$rating = ($ratingRaw !== '' && $ratingRaw !== null) ? (float)$ratingRaw : null;
|
$rating = ($ratingRaw !== '' && $ratingRaw !== null) ? (float)$ratingRaw : null;
|
||||||
$review = $rowData['Review'] ?? $rowData['review'] ?? '';
|
$review = $rowData['Review'] ?? $rowData['review'] ?? '';
|
||||||
@@ -598,8 +612,9 @@ case 'get_config_keys':
|
|||||||
if (empty($streaming)) $streaming = 'Support physique / Cinéma';
|
if (empty($streaming)) $streaming = 'Support physique / Cinéma';
|
||||||
|
|
||||||
$stmtCritiques->execute([$id, $title, $year, $director, $poster, $rating, $review, $streaming]);
|
$stmtCritiques->execute([$id, $title, $year, $director, $poster, $rating, $review, $streaming]);
|
||||||
|
$imported++;
|
||||||
}
|
}
|
||||||
$imported++;
|
}
|
||||||
$pdo->commit();
|
$pdo->commit();
|
||||||
echo json_encode(["success" => true, "imported" => $imported]);
|
echo json_encode(["success" => true, "imported" => $imported]);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user