Fix twice issue

This commit is contained in:
2026-07-11 11:13:35 +02:00
parent b44a5a39e1
commit b958d94876
+12 -2
View File
@@ -10,9 +10,19 @@ class Movie {
}
// Ajoute un film (toujours en perso par défaut)
public function add($userId, $tmdbId, $title, $posterPath, $type) {
public function add($userId, $tmdbId, $title, $poster, $type) {
// 1. On vérifie si le film existe déjà pour cet utilisateur
$stmt = $this->db->prepare("SELECT id FROM movies WHERE user_id = ? AND tmdb_id = ?");
$stmt->execute([$userId, $tmdbId]);
if ($stmt->fetch()) {
// Le film est déjà dans la liste de cet utilisateur
return false;
}
// 2. Sinon, on insère
$stmt = $this->db->prepare("INSERT INTO movies (user_id, tmdb_id, title, poster_path, media_type, is_common) VALUES (?, ?, ?, ?, ?, 0)");
return $stmt->execute([$userId, $tmdbId, $title, $posterPath, $type]);
return $stmt->execute([$userId, $tmdbId, $title, $poster, $type]);
}
// Bascule un film en "Commune"