From aa05e82ca524b4bf5baf38089f0898f84d53a184 Mon Sep 17 00:00:00 2001 From: Felix-Vimalaratnam Date: Mon, 27 May 2024 13:32:33 +0200 Subject: [PATCH] ajout chansons --- .../application/controllers/Chansons.php | 19 +++++++++++++++++++ .../application/models/Model_music.php | 14 ++++++++++++++ .../application/views/chansons_list.php | 15 +++++++++++++++ .../application/views/layout/header.php | 1 + 4 files changed, 49 insertions(+) create mode 100644 CodeIgniter-3.1.13/application/controllers/Chansons.php create mode 100644 CodeIgniter-3.1.13/application/views/chansons_list.php diff --git a/CodeIgniter-3.1.13/application/controllers/Chansons.php b/CodeIgniter-3.1.13/application/controllers/Chansons.php new file mode 100644 index 0000000..0bdcf6f --- /dev/null +++ b/CodeIgniter-3.1.13/application/controllers/Chansons.php @@ -0,0 +1,19 @@ +load->model('model_music'); + $this->load->helper('html'); + $this->load->helper('url'); + } + public function index(){ + $chansons = $this->model_music->getChansons(); + $this->load->view('layout/header'); + $this->load->view('chansons_list',['chansons'=>$chansons]); + $this->load->view('layout/footer'); + } + +} diff --git a/CodeIgniter-3.1.13/application/models/Model_music.php b/CodeIgniter-3.1.13/application/models/Model_music.php index 46f1380..26a1035 100644 --- a/CodeIgniter-3.1.13/application/models/Model_music.php +++ b/CodeIgniter-3.1.13/application/models/Model_music.php @@ -27,4 +27,18 @@ class Model_music extends CI_Model { ); return $query->result(); } + + public function getChansons(){ + $query = $this->db->query( + "SELECT song.name,song.id,album.year,album.name as albumName, artist.name as artistName, genre.name as genreName + FROM song + JOIN track ON track.songId = song.id + JOIN album ON album.id = track.albumId + JOIN artist ON album.artistid = artist.id + JOIN genre ON genre.id = album.genreid + ORDER BY album.year + " + ); + return $query->result(); + } } diff --git a/CodeIgniter-3.1.13/application/views/chansons_list.php b/CodeIgniter-3.1.13/application/views/chansons_list.php new file mode 100644 index 0000000..a59ca32 --- /dev/null +++ b/CodeIgniter-3.1.13/application/views/chansons_list.php @@ -0,0 +1,15 @@ +
Chansons list
+
+
"; + echo "
"; + echo anchor("albums/view/{$chansons->id}","{$chansons->name}"); + echo "
"; + echo ""; + echo ""; + echo "
{$chansons->year} - {$chansons->artistName}
+
"; +} +?> +
\ No newline at end of file diff --git a/CodeIgniter-3.1.13/application/views/layout/header.php b/CodeIgniter-3.1.13/application/views/layout/header.php index cb0119d..6c48c15 100644 --- a/CodeIgniter-3.1.13/application/views/layout/header.php +++ b/CodeIgniter-3.1.13/application/views/layout/header.php @@ -20,6 +20,7 @@