views artistes
This commit is contained in:
@@ -123,27 +123,37 @@ class Model_music extends CI_Model {
|
||||
|
||||
return array('album' => $albumDetails, 'songs' => $songs);
|
||||
}
|
||||
|
||||
public function getArtistDetails($artistId) {
|
||||
// Get artist info
|
||||
$this->db->select('artist.name as artistName, artist.id, genre.name as genreName, artist.jpeg');
|
||||
$this->db->from('artist');
|
||||
$this->db->join('album', 'album.artistid = artist.id', 'left');
|
||||
$this->db->join('genre', 'album.genreid = genre.id', 'left');
|
||||
$this->db->where('artist.id', $artistId);
|
||||
$artistQuery = $this->db->get();
|
||||
$artistDetails = $artistQuery->row();
|
||||
|
||||
// Get artist's albums
|
||||
// Get artist's albums with their songs
|
||||
$this->db->select('album.id as albumId, album.name as albumName, album.year');
|
||||
$this->db->from('album');
|
||||
$this->db->where('album.artistid', $artistId);
|
||||
$albumsQuery = $this->db->get();
|
||||
$albums = $albumsQuery->result();
|
||||
|
||||
// Get songs for each album
|
||||
foreach ($albums as $album) {
|
||||
$this->db->select('track.id as trackId, song.name as songName');
|
||||
$this->db->from('track');
|
||||
$this->db->join('song', 'track.songid = song.id');
|
||||
$this->db->where('track.albumid', $album->albumId);
|
||||
$album->songs = $this->db->get()->result();
|
||||
}
|
||||
|
||||
return array('artist' => $artistDetails, 'albums' => $albums);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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');
|
||||
|
Reference in New Issue
Block a user