diff --git a/ci/application/controllers/Albums.php b/ci/application/controllers/Albums.php index 9a7b883..a4d9a3d 100644 --- a/ci/application/controllers/Albums.php +++ b/ci/application/controllers/Albums.php @@ -13,11 +13,5 @@ class Albums extends CI_Controller { $this->load->view('albums_list',['albums'=>$albums]); $this->load->view('layout/footer'); } - public function view($album_id){ - $songs = $this->model_music->getSongOfAlbum($album_id); - $this->load->view('layout/header'); - $this->load->view('song_album_list',['songs'=>$songs]); - $this->load->view('layout/footer'); - } } diff --git a/ci/application/controllers/Artistes.php b/ci/application/controllers/Artistes.php index df69139..cfb25dc 100644 --- a/ci/application/controllers/Artistes.php +++ b/ci/application/controllers/Artistes.php @@ -13,5 +13,11 @@ class artistes extends CI_Controller { $this->load->view('artistes_list',['artistes'=>$artistes]); $this->load->view('layout/footer'); } + public function view($AlbumsOfArtistId){ + $AlbumsOfArtist = $this->model_music->getAlbumsOfArtist($AlbumsOfArtistId); + $this->load->view('layout/header'); + $this->load->view('albums_artist_list',['AlbumsOfArtist'=>$AlbumsOfArtist]); + $this->load->view('layout/footer'); + } } \ No newline at end of file diff --git a/ci/application/controllers/Song.php b/ci/application/controllers/Song.php new file mode 100644 index 0000000..77b552a --- /dev/null +++ b/ci/application/controllers/Song.php @@ -0,0 +1,17 @@ +load->model('model_music'); + } + + public function view($album_id){ + $songs = $this->model_music->getSongOfAlbum($album_id); + $this->load->view('layout/header'); + $this->load->view('song_album_list',['songs'=>$songs]); + $this->load->view('layout/footer'); + } +} \ No newline at end of file diff --git a/ci/application/models/Model_music.php b/ci/application/models/Model_music.php index 2297c38..4d68449 100644 --- a/ci/application/models/Model_music.php +++ b/ci/application/models/Model_music.php @@ -35,7 +35,21 @@ class Model_music extends CI_Model { INNER JOIN track ON song.id = track.songId WHERE track.albumId = ?", array($album_id) - ); + ); return $query->result(); } + + public function getAlbumsOfArtist($artist_id){ + $query = $this->db->query( + "SELECT album.name, album.id, album.year, genre.name as genreName, cover.jpeg + FROM album + JOIN artist ON album.artistId = artist.id + JOIN genre ON album.genreId = genre.id + JOIN cover ON album.coverId = cover.id + WHERE artist.id = ?", + array($artist_id) + ); + return $query->result(); + } + } diff --git a/ci/application/views/albums_artist_list.php b/ci/application/views/albums_artist_list.php new file mode 100644 index 0000000..107f92b --- /dev/null +++ b/ci/application/views/albums_artist_list.php @@ -0,0 +1,15 @@ +
Albums of the artist
+
+
"; + echo "
"; + echo anchor("albums/view/{$AlbumOfArtists->id}","{$AlbumOfArtists->name}"); + echo "
"; + echo "
"; + echo "
"; +} +?> +
\ No newline at end of file diff --git a/ci/application/views/albums_list.php b/ci/application/views/albums_list.php index 0fd49bb..45d0462 100644 --- a/ci/application/views/albums_list.php +++ b/ci/application/views/albums_list.php @@ -4,7 +4,7 @@ foreach($albums as $album){ echo "
"; echo "
"; - echo anchor("albums/view/{$album->id}","{$album->name}"); + echo anchor("Song/view/{$album->id}","{$album->name}"); echo "
"; echo ''; echo "