From f1638ed86545873b70a3e827c894739a310639a7 Mon Sep 17 00:00:00 2001 From: brigitte Date: Thu, 30 May 2024 16:14:38 +0200 Subject: [PATCH] crea BD playlist + liste des playlists --- ci/application/config/config.php | 2 +- ci/application/controllers/Albums.php | 4 ++-- ci/application/controllers/Artistes.php | 2 +- ci/application/controllers/Playlist.php | 17 +++++++++++++++++ ci/application/models/Model_music.php | 10 ++++++++++ ci/application/views/artistes_list.php | 4 ++-- ci/application/views/playlist_list.php | 11 +++++++++++ 7 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 ci/application/views/playlist_list.php diff --git a/ci/application/config/config.php b/ci/application/config/config.php index bfc3804..3efe38d 100644 --- a/ci/application/config/config.php +++ b/ci/application/config/config.php @@ -23,7 +23,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); | a PHP script and you can easily do that on your own. | */ -$config['base_url'] = '/~boutaric/SAEWEB2.2/ci/'; +$config['base_url'] = '/~brigitte/SAEWEB2.2/ci/'; /* |-------------------------------------------------------------------------- diff --git a/ci/application/controllers/Albums.php b/ci/application/controllers/Albums.php index 5afc1b1..8ef84c9 100644 --- a/ci/application/controllers/Albums.php +++ b/ci/application/controllers/Albums.php @@ -18,9 +18,9 @@ class Albums extends CI_Controller { public function view($album_id){ $songs = $this->model_music->getSongOfAlbum($album_id); if (empty($songs)) { - $songs = []; // Assurez-vous que $songs est un tableau vide si aucune chanson n'est trouvée + $songs = []; } - // Debugging: Log the $songs variable to see its content + log_message('debug', 'Songs: ' . print_r($songs, true)); $this->load->view('layout/header_album'); diff --git a/ci/application/controllers/Artistes.php b/ci/application/controllers/Artistes.php index 2814e7b..1c0b024 100644 --- a/ci/application/controllers/Artistes.php +++ b/ci/application/controllers/Artistes.php @@ -18,7 +18,7 @@ class artistes extends CI_Controller { $AlbumsOfArtist = $this->model_music->getAlbumsOfArtist($AlbumsOfArtistId); $this->load->view('layout/header_artistes'); $this->load->view('albums_artist_list',['AlbumsOfArtist'=>$AlbumsOfArtist]); - $this->load->view('layout/footer'); + $this->load->view('layout/footer_artistes'); } } \ No newline at end of file diff --git a/ci/application/controllers/Playlist.php b/ci/application/controllers/Playlist.php index e69de29..8625daa 100644 --- a/ci/application/controllers/Playlist.php +++ b/ci/application/controllers/Playlist.php @@ -0,0 +1,17 @@ +load->model('model_music'); + } + + public function index(){ + $playlists = $this->model_music->getPlaylist(); + //$this->load->view('layout/header_album'); + $this->load->view('playlist_list', ['playlists' => $playlists]); + //$this->load->view('layout/footer_album'); + } +} \ No newline at end of file diff --git a/ci/application/models/Model_music.php b/ci/application/models/Model_music.php index 4d68449..3b070f8 100644 --- a/ci/application/models/Model_music.php +++ b/ci/application/models/Model_music.php @@ -28,6 +28,16 @@ class Model_music extends CI_Model { return $query->result(); } + public function getPlaylist(){ + $query = $this->db->query( + "SELECT playlist.id, playlist.name + FROM playlist + Group by playlist.id + " + ); + return $query->result(); + } + public function getSongOfAlbum($album_id){ $query = $this->db->query( "SELECT song.id, song.name diff --git a/ci/application/views/artistes_list.php b/ci/application/views/artistes_list.php index 906ebc5..4b263ad 100644 --- a/ci/application/views/artistes_list.php +++ b/ci/application/views/artistes_list.php @@ -1,10 +1,10 @@
Artists list
"; //echo "
"; - echo anchor("artistes/view/{$artistes->id}","{$artistes->name}"); + echo anchor("artistes/view/{$artiste->id}","{$artiste->name}"); echo "
"; echo "
"; //echo "
{$artistes->year} - {$artistes->artistName}
diff --git a/ci/application/views/playlist_list.php b/ci/application/views/playlist_list.php new file mode 100644 index 0000000..7493091 --- /dev/null +++ b/ci/application/views/playlist_list.php @@ -0,0 +1,11 @@ +
Playlist List
+
"; + echo "
"; + echo anchor("playlists/view/{$playlist->id}","{$playlist->name}"); + echo "
"; + echo "
"; + echo "
"; +} +?>