diff --git a/CodeIgniter-3.1.13/application/controllers/Albums.php b/CodeIgniter-3.1.13/application/controllers/Albums.php index fb7ad45..b65d6c2 100644 --- a/CodeIgniter-3.1.13/application/controllers/Albums.php +++ b/CodeIgniter-3.1.13/application/controllers/Albums.php @@ -10,8 +10,18 @@ class Albums extends CI_Controller { $this->load->helper('url'); } public function index(){ - $albums = $this->model_music->getAlbums(); + if ($recherche=filter_input(INPUT_GET,'recherche') == false or $recherche=filter_input(INPUT_GET,'recherche') == null){ + $albums = $this->model_music->getAlbums(); + }else{ + $recherche=filter_input(INPUT_GET,'recherche'); + $albums = $this->model_music->getSearchAlbums($recherche); + } $this->load->view('layout/header'); + if ($albums == false){ + $page = preg_split('/[\/]/',$_SERVER['HTTP_REFERER']); + $this->load->view('error',['page'=>$page[count($page)-1]]); + $albums = $this->model_music->getAlbums(); + } $this->load->view('albums_list',['albums'=>$albums]); $this->load->view('layout/footer'); } diff --git a/CodeIgniter-3.1.13/application/controllers/Artistes.php b/CodeIgniter-3.1.13/application/controllers/Artistes.php index 6ed3bcf..9c6d6f4 100644 --- a/CodeIgniter-3.1.13/application/controllers/Artistes.php +++ b/CodeIgniter-3.1.13/application/controllers/Artistes.php @@ -10,8 +10,18 @@ class Artistes extends CI_Controller { $this->load->helper('url'); } public function index(){ - $artistes = $this->model_music->getArtistes(); + if ($recherche=filter_input(INPUT_GET,'recherche') == false or $recherche=filter_input(INPUT_GET,'recherche') == null){ + $artistes = $this->model_music->getArtistes(); + }else{ + $recherche=filter_input(INPUT_GET,'recherche');= $this->model_music->getSearchArtistes($recherche); + $artistes = $this->model_music->getSearchArtistes($recherche); + } $this->load->view('layout/header'); + if ($artistes == false){ + $page = preg_split('/[\/]/',$_SERVER['HTTP_REFERER']); + $this->load->view('error',['page'=>$page[count($page)-1]]); + $artistes = $this->model_music->getArtistes(); + } $this->load->view('artistes_list',['artistes'=>$artistes]); $this->load->view('layout/footer'); } diff --git a/CodeIgniter-3.1.13/application/controllers/Chansons.php b/CodeIgniter-3.1.13/application/controllers/Chansons.php index 0bdcf6f..a2b37ba 100644 --- a/CodeIgniter-3.1.13/application/controllers/Chansons.php +++ b/CodeIgniter-3.1.13/application/controllers/Chansons.php @@ -10,10 +10,21 @@ class Chansons extends CI_Controller { $this->load->helper('url'); } public function index(){ - $chansons = $this->model_music->getChansons(); + if ($recherche=filter_input(INPUT_GET,'recherche') == false or $recherche=filter_input(INPUT_GET,'recherche') == null){ + $chansons = $this->model_music->getChansons(); + }else{ + $recherche=filter_input(INPUT_GET,'recherche'); + $chansons = $this->model_music->getSearchChansons($recherche); + } $this->load->view('layout/header'); + if ($chansons == false){ + $page = preg_split('/[\/]/',$_SERVER['HTTP_REFERER']); + $this->load->view('error',['page'=>$page[count($page)-1]]); + $chansons = $this->model_music->getChansons(); + } $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 26a1035..b0aa604 100644 --- a/CodeIgniter-3.1.13/application/models/Model_music.php +++ b/CodeIgniter-3.1.13/application/models/Model_music.php @@ -41,4 +41,54 @@ class Model_music extends CI_Model { ); return $query->result(); } + + public function getSearchAlbums($nom){ + $query = $this->db->query( + "SELECT album.name,album.id,year,artist.name as artistName, genre.name as genreName,jpeg + FROM album + JOIN artist ON album.artistid = artist.id + JOIN genre ON genre.id = album.genreid + JOIN cover ON cover.id = album.coverid + WHERE album.name LIKE '$nom' + " + ); + $query->result(); + if ($query->num_rows() > 0){ + return $query; + } + return $query = false; + } + + public function getSearchArtistes($nom){ + $query = $this->db->query( + "SELECT artist.name, artist.id + FROM artist + WHERE artist.name LIKE '$nom' + " + ); + $query->result(); + if ($query->num_rows() > 0){ + return $query; + } + return $query = false; + } + + public function getSearchChansons($nom){ + $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 + WHERE song.name LIKE '$nom' + + " + ); + $query->result(); + if ($query->num_rows() > 0){ + return $query; + } + return $query = false; + } } diff --git a/CodeIgniter-3.1.13/application/views/error.php b/CodeIgniter-3.1.13/application/views/error.php new file mode 100644 index 0000000..9d251e8 --- /dev/null +++ b/CodeIgniter-3.1.13/application/views/error.php @@ -0,0 +1 @@ + $page non trouvé";?> \ 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 6c48c15..c9d5ade 100644 --- a/CodeIgniter-3.1.13/application/views/layout/header.php +++ b/CodeIgniter-3.1.13/application/views/layout/header.php @@ -16,6 +16,9 @@