Actualiser api.php
This commit is contained in:
@@ -790,19 +790,21 @@ case 'get_films':
|
|||||||
// 1. Récupération des critiques
|
// 1. Récupération des critiques
|
||||||
$critiques = $pdo->query("SELECT id, title, year, director, poster, rating, review, NULL AS description, streaming, 'critique' AS type, NULL AS format FROM critiques ORDER BY id DESC")->fetchAll();
|
$critiques = $pdo->query("SELECT id, title, year, director, poster, rating, review, NULL AS description, streaming, 'critique' AS type, NULL AS format FROM critiques ORDER BY id DESC")->fetchAll();
|
||||||
|
|
||||||
// Correction des notes (format entier si rond)
|
// CORRECTION : Utilisation du & pour modifier le tableau original
|
||||||
foreach ($critiques as $row) {
|
foreach ($critiques as $row) {
|
||||||
if ($row['rating'] !== null) {
|
if ($row['rating'] !== null) {
|
||||||
$ratingVal = (float)$row['rating'];
|
$ratingVal = (float)$row['rating'];
|
||||||
$row['rating'] = ($ratingVal == floor($ratingVal)) ? (int)$ratingVal : $ratingVal;
|
$row['rating'] = ($ratingVal == floor($ratingVal)) ? (int)$ratingVal : $ratingVal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($row);
|
unset($row); // Sécurité pour libérer la référence
|
||||||
|
|
||||||
// 2. Récupération de la vidéothèque
|
// 2. Récupération de la vidéothèque
|
||||||
$videotheque = $pdo->query("SELECT id, title, year, director, poster, NULL AS rating, NULL AS review, description, NULL AS streaming, 'videotheque' AS type, format FROM videotheque ORDER BY id DESC")->fetchAll();
|
$videotheque = $pdo->query("SELECT id, title, year, director, poster, NULL AS rating, NULL AS review, description, NULL AS streaming, 'videotheque' AS type, format FROM videotheque ORDER BY id DESC")->fetchAll();
|
||||||
|
|
||||||
// 3. Retourne les deux listes séparées
|
// LOGGING : Utile pour voir dans php_errors.log si les tables sont vides
|
||||||
|
error_log("API get_films - Critiques trouvées: " . count($critiques) . " | Vidéothèque: " . count($videotheque));
|
||||||
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'critiques' => $critiques,
|
'critiques' => $critiques,
|
||||||
'videotheque' => $videotheque
|
'videotheque' => $videotheque
|
||||||
|
|||||||
Reference in New Issue
Block a user