Fix twice issue
This commit is contained in:
+12
-2
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user