validateur validé

This commit is contained in:
2024-06-17 18:43:13 +02:00
parent 6b9efb4dd0
commit d06ea90853
18 changed files with 348 additions and 313 deletions

View File

@@ -118,7 +118,8 @@ class Model_music extends CI_Model {
}
public function get_filtered_sorted_chansons($genres = [], $artists = [], $years = [], $albums = [], $sort_column = 'id', $sort_order = 'asc', $limit = 100, $offset = 0) {
$this->db->select('track.id as trackId, song.name,song.id,album.year,album.name as albumName, artist.name as artistName, genre.name as genreName');
$this->db->distinct('song.id');
$this->db->select('track.id as trackId, song.name,album.year,album.name as albumName, artist.name as artistName, genre.name as genreName');
$this->db->from('song');
$this->db->join('track', 'track.songId = song.id');
$this->db->join('album', 'album.id = track.albumId');
@@ -400,7 +401,52 @@ class Model_music extends CI_Model {
if ($result->num_rows() > 0) {
return true;
}
return $query = false;
return false;
}
public function SongInThisPlaylist($idtrack,$idplaylist){
if (!is_array($idtrack)) {
$idtrack = array($idtrack);
}
// Étape 1: Récupérer l'ID de la chanson à partir de l'un des IDs de piste fournis
$this->db->select('song.id as songId');
$this->db->from('track');
$this->db->join('song', 'song.id = track.songId');
$this->db->where_in('track.id', $idtrack);
$query = $this->db->get();
// Vérifier si des résultats ont été trouvés
if ($query->num_rows() == 0) {
return false; // Si aucun résultat trouvé, retourner false
}
// Récupérer le premier songId correspondant
$result = $query->row();
$songId = $result->songId;
// Étape 2: Récupérer tous les IDs de pistes associés à cette chanson
$this->db->select('track.id as trackId');
$this->db->from('track');
$this->db->where('track.songId', $songId);
$query = $this->db->get();
$trackIds = array();
foreach ($query->result() as $track) {
$trackIds[] = $track->trackId;
}
// Étape 3: Vérifier si l'une des pistes de cette chanson est dans la playlist
$this->db->select('PlaylistSong.trackid as trackId');
$this->db->from('PlaylistSong');
$this->db->where_in('PlaylistSong.trackid', $trackIds);
$this->db->where('PlaylistSong.playlistId',$idplaylist);
$query = $this->db->get();
// Si on trouve au moins une piste de cette chanson dans la playlist, retourner true
if ($query->num_rows() > 0) {
return true;
}
return false;
}
public function TrackidSonginPlaylist($id) {