From c98f0758c8097ad7194716eef2d1c98884a0ac46 Mon Sep 17 00:00:00 2001 From: brigitte Date: Tue, 28 May 2024 11:34:30 +0200 Subject: [PATCH] album(s) des artistes --- ci/application/controllers/Albums.php | 6 ------ ci/application/controllers/Artistes.php | 6 ++++++ ci/application/controllers/Song.php | 17 +++++++++++++++++ ci/application/models/Model_music.php | 16 +++++++++++++++- ci/application/views/albums_artist_list.php | 15 +++++++++++++++ ci/application/views/albums_list.php | 2 +- 6 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 ci/application/controllers/Song.php create mode 100644 ci/application/views/albums_artist_list.php 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 "