finition css

This commit is contained in:
2024-06-18 19:59:50 +02:00
parent 0b4dde90ac
commit 24fa946cf0
7 changed files with 133 additions and 112 deletions

View File

@@ -176,16 +176,14 @@ class Model_music extends CI_Model {
}
public function getSearchAlbums($nom){
$query = $this->db->query(
"SELECT album.name,album.id as albumId,year,artist.name as artistName, genre.name as genreName,jpeg
FROM album
JOIN artist ON album.artistid = artist.id
JOIN genre ON genre.id = album.genreid
JOIN cover ON cover.id = album.coverid
WHERE album.name LIKE '$nom'
"
);
//$query->result();
$this->db->select('album.name,album.id as albumId,year,artist.name as artistName, genre.name as genreName,jpeg ');
$this->db->from('album');
$this->db->join('artist','album.artistid = artist.id');
$this->db->join('genre','genre.id = album.genreid');
$this->db->join('cover','cover.id = album.coverid');
$this->db->where('album.name', $nom);
$this->db->order_by('year','ASC');
$query = $this->db->get();
if ($query->num_rows() > 0){
return $query->result();
}
@@ -193,13 +191,10 @@ class Model_music extends CI_Model {
}
public function getSearchArtistes($nom){
$query = $this->db->query(
"SELECT artist.name, artist.id
FROM artist
WHERE artist.name LIKE '$nom'
"
);
$query->result();
$this->db->select('artist.name, artist.id');
$this->db->from('artist');
$this->db->like('artist.name',$nom);
$query = $this->db->get();
if ($query->num_rows() > 0){
return $query->result();
}
@@ -207,18 +202,15 @@ class Model_music extends CI_Model {
}
public function getSearchChansons($nom){
$query = $this->db->query(
"SELECT track.id as trackId,song.name,song.id,album.year,album.name as albumName, artist.name as artistName, genre.name as genreName
FROM song
JOIN track ON track.songId = song.id
JOIN album ON album.id = track.albumId
JOIN artist ON album.artistid = artist.id
JOIN genre ON genre.id = album.genreid
WHERE song.name LIKE '$nom'
"
);
$query->result();
$this->db->select('album.name,album.id as albumId,year,artist.name as artistName, genre.name as genreName,jpeg ');
$this->db->from('song');
$this->db->join('track','track.songId = song.id');
$this->db->join('album','track.artistid = album.id');
$this->db->join('artist','album.artistid = artist.id');
$this->db->join('genre','genre.id = album.genreid');
$this->db->where('song.name', $nom);
$this->db->order_by('year','ASC');
$query = $this->db->get();
if ($query->num_rows() > 0){
return $query->result();
}
@@ -230,18 +222,16 @@ class Model_music extends CI_Model {
$query = $this->db->get('album');
$album = $query->row();
// Recupere la couverture
$this->db->where('id', $album->coverId);
$coverQuery = $this->db->get('cover');
$cover = $coverQuery->row();
$album->coverImage = $cover->jpeg;
// Recupere le l'id de la musique a partie de l'album
$this->db->select('songId');
$this->db->where('albumId', $id);
$songsQuery = $this->db->get('track');
$songIds = $songsQuery->result();
// Récupérer les noms des chansons à partir des songIds
$album->songs = [];
foreach ($songIds as $song) {
$this->db->select('name');
@@ -272,22 +262,18 @@ class Model_music extends CI_Model {
$artist = $artistQuery->row();
$album->artist = $artist;
return $album;
}
public function getAlbumsByArtistId($artistId) {
$query = $this->db->query(
"SELECT album.name,album.id as albumId,year,artist.name as artistName, genre.name as genreName,jpeg
FROM album
JOIN artist ON album.artistid = artist.id
JOIN genre ON genre.id = album.genreid
JOIN cover ON cover.id = album.coverid
WHERE album.artistid=$artistId
ORDER BY year
"
);
$this->db->select('album.name,album.id as albumId,year,artist.name as artistName, genre.name as genreName,jpeg');
$this->db->from('album');
$this->db->join('artist','album.artistid = artist.id');
$this->db->join('genre','genre.id = album.genreid');
$this->db->join('cover','cover.id = album.coverid');
$this->db->where('album.artistid', $artistId);
$this->db->order_by('year','ASC');
$query = $this->db->get();
return $query->result();
}
@@ -305,23 +291,20 @@ class Model_music extends CI_Model {
return $query->row();
}
public function getPlaylist(){
$query = $this->db->query(
"SELECT Playlist.name, Playlist.playlistId
FROM Playlist
ORDER BY Playlist.name
"
);
return $query->result();
public function getPlaylist($iduser){
$this->db->select("Playlist.name, Playlist.playlistId");
$this->db->from('Playlist');
$this->db->where('Playlist.userId',$iduser);
$query = $this->db->get();
return $query->result();
}
public function getSearchPlaylist($nom){
$query = $this->db->query(
"SELECT Playlist.name, Playlist.playlistId
FROM Playlist
WHERE Playlist.name LIKE '$nom'
"
);
public function getSearchPlaylist($nom,$iduser){
$this->db->select("Playlist.name, Playlist.playlistId");
$this->db->from('Playlist');
$this->db->where('Playlist.name',$nom);
$this->db->where('Playlist.userId',$iduser);
$query = $this->db->get();
$query->result();
if ($query->num_rows() > 0){
return $query->result();
@@ -335,14 +318,12 @@ class Model_music extends CI_Model {
$track = $result->row();
$trackId = $track->trackId;
$query = $this->db->query(
"SELECT Playlist.name, Playlist.playlistId
FROM Playlist
JOIN PlaylistSong ON Playlist.playlistId = PlaylistSong.playlistId
WHERE PlaylistSong.trackId = $trackId
ORDER BY Playlist.name
"
);
$this->db->select('Playlist.name, Playlist.playlistId');
$this->db->from('Playlist');
$this->db->join('PlaylistSong','Playlist.playlistId = PlaylistSong.playlistId');
$this->db->where('PlaylistSong.trackId',$trackId);
$this->db->order_by('Playlist.name','ASC');
$query = $this->db->get();
return $query->result();
}
@@ -387,7 +368,6 @@ class Model_music extends CI_Model {
public function SongInPlaylist($id){
$result = $this->model_music->TrackidSonginPlaylist($id);
// Si on trouve au moins une piste de cette chanson dans la playlist, retourner true
if ($result->num_rows() > 0) {
return true;
}
@@ -399,23 +379,19 @@ class Model_music extends CI_Model {
$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
return 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);
@@ -425,14 +401,12 @@ class Model_music extends CI_Model {
$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;
}
@@ -444,23 +418,19 @@ class Model_music extends CI_Model {
$id = array($id);
}
// É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', $id);
$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
return 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);
@@ -470,7 +440,6 @@ class Model_music extends CI_Model {
$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);
@@ -554,9 +523,23 @@ class Model_music extends CI_Model {
$this->db->where_in('year', $years);
}
$this->db->order_by('RAND()');
$this->db->order_by('trackId','RANDOM');
$this->db->limit($num_tracks);
$query = $this->db->get();
return $query->result();
}
public function verifyMail($email){
$this->db->select('usermail');
$this->db->from('User');
$this->db->where('usermail', $email);
$query = $this->db->get();
if($query->num_rows() > 0){
return true;
}
return false;
}
}