Add Remove & Mark watched movie

This commit is contained in:
2026-07-11 14:08:44 +02:00
parent 535fe6041b
commit 72d563416b
2 changed files with 35 additions and 4 deletions
+21 -4
View File
@@ -33,7 +33,7 @@ class Movie {
}
return true;
}
}
public function share($movieId, $userId) {
$stmt = $this->db->prepare("UPDATE movies SET is_common = 1 WHERE id = ? AND user_id = ?");
@@ -56,10 +56,27 @@ class Movie {
}
// 3. Commune
$stmt = $this->db->prepare("SELECT * FROM movies WHERE is_common = 1 ORDER BY added_at DESC");
$stmt->execute();
$common = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt = $this->db->prepare("
SELECT *
FROM movies
WHERE is_common = 1
GROUP BY tmdb_id
ORDER BY added_at DESC
");
$stmt->execute();
$common = $stmt->fetchAll(PDO::FETCH_ASSOC);
return ["perso" => $perso, "partner" => $partner, "common" => $common];
}
public function remove($movieId, $userId) {
$stmt = $this->db->prepare("DELETE FROM movies WHERE id = ? AND user_id = ?");
return $stmt->execute([$movieId, $userId]);
}
public function markWatched($movieId, $userId) {
// Si tu n'as pas de colonne 'watched', ajoute-la en BDD : ALTER TABLE movies ADD COLUMN watched BOOLEAN DEFAULT 0;
$stmt = $this->db->prepare("UPDATE movies SET watched = 1 WHERE id = ? AND user_id = ?");
return $stmt->execute([$movieId, $userId]);
}
}