adding views songs

This commit is contained in:
Vincent
2024-06-05 01:15:45 +02:00
parent 9318110b0c
commit 9dc667796e
3 changed files with 45 additions and 30 deletions

View File

@@ -152,24 +152,36 @@ class Model_music extends CI_Model {
}
public function getSongDetails($songId) {
// Get song details
$this->db->select('song.name as songName, track.id as trackId, album.name as albumName, album.year, artist.name as artistName, genre.name as genreName, cover.jpeg');
$this->db->from('track');
$this->db->join('song', 'track.songId = song.id');
$this->db->join('album', 'track.albumId = album.id');
$this->db->join('artist', 'album.artistid = artist.id');
$this->db->join('genre', 'album.genreid = genre.id');
$this->db->join('cover', 'album.coverid = cover.id');
$this->db->where('track.id', $songId);
$this->db->select('song.name as songName, song.id');
$this->db->from('song');
$this->db->where('song.id', $songId);
$songQuery = $this->db->get();
return $songQuery->row();
$songDetails = $songQuery->row();
// Get album details for the song
$this->db->select('album.id as albumId, album.name as albumName, album.year');
$this->db->from('album');
$this->db->join('track', 'track.albumid = album.id');
$this->db->where('track.songid', $songId);
$albumQuery = $this->db->get();
$albumDetails = $albumQuery->row();
// Get artist details for the album
$this->db->select('artist.id as artistId, artist.name as artistName');
$this->db->from('artist');
$this->db->join('album', 'album.artistid = artist.id');
$this->db->where('album.id', $albumDetails->albumId);
$artistQuery = $this->db->get();
$artistDetails = $artistQuery->row();
return array('song' => $songDetails, 'album' => $albumDetails, 'artist' => $artistDetails);
}
// Suppression de la deuxième méthode researchtype