diff --git a/CodeIgniter-3.1.13/application/config/config.php b/CodeIgniter-3.1.13/application/config/config.php index e3ce1e5..c4f49b2 100644 --- a/CodeIgniter-3.1.13/application/config/config.php +++ b/CodeIgniter-3.1.13/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'] = 'https://dwarves.iut-fbleau.fr/~orfao/SAE/SAE_2.02/CodeIgniter-3.1.13/'; +$config['base_url'] = 'https://dwarves.iut-fbleau.fr/~stiti/SAE_2.02/CodeIgniter-3.1.13/'; /* |-------------------------------------------------------------------------- diff --git a/CodeIgniter-3.1.13/application/controllers/Search.php b/CodeIgniter-3.1.13/application/controllers/Search.php index 4e9be37..985f5ff 100644 --- a/CodeIgniter-3.1.13/application/controllers/Search.php +++ b/CodeIgniter-3.1.13/application/controllers/Search.php @@ -5,18 +5,14 @@ class Search extends CI_Controller { public function __construct(){ parent::__construct(); - $this->load->model('Search_model'); - $this->load->helper('url'); - $this->load->helper('html'); + $this->load->model('Search_model'); + $this->load->helper(['url', 'html']); } public function index(){ - // Récupérer la requête de recherche depuis la barre de recherche $query = $this->input->get('query'); - // Vérifier que la requête de recherche n'est pas vide if (empty($query)) { - // Charger la vue avec un message d'erreur $data['query'] = $query; $data['musiques'] = []; $data['albums'] = []; @@ -24,33 +20,32 @@ class Search extends CI_Controller { $data['artistes'] = []; $data['error'] = "La requête de recherche ne peut pas être vide."; - $data['title']="Résultats de la recherche"; - $data['css']="assets/css/search_results"; + $data['title'] = "Résultats de la recherche"; + $data['css'] = "assets/css/search_results"; $this->load->view('layout/header_dark', $data); - $this->load->view('search_results',$data); + $this->load->view('search_results', $data); $this->load->view('layout/footer_dark'); return; } - // Faire une recherche dans les musiques, les albums, les genres et les artistes $musiques = $this->Search_model->searchMusiques($query); $albums = $this->Search_model->searchAlbums($query); $genres = $this->Search_model->searchGenres($query); $artistes = $this->Search_model->searchArtistes($query); - // Charger la vue avec les résultats de la recherche $data['query'] = $query; $data['musiques'] = $musiques; $data['albums'] = $albums; $data['genres'] = $genres; $data['artistes'] = $artistes; - $data['title']="Résultats de la recherche"; - $data['css']="assets/css/search_results"; + $data['title'] = "Résultats de la recherche"; + $data['css'] = "assets/css/search_results"; $this->load->view('layout/header_dark', $data); - $this->load->view('search_results',$data); + $this->load->view('search_results', $data); $this->load->view('layout/footer_dark'); } } +?> diff --git a/CodeIgniter-3.1.13/application/models/Search_model.php b/CodeIgniter-3.1.13/application/models/Search_model.php index 4b15113..cea12ec 100644 --- a/CodeIgniter-3.1.13/application/models/Search_model.php +++ b/CodeIgniter-3.1.13/application/models/Search_model.php @@ -22,7 +22,7 @@ class Search_model extends CI_Model { } public function searchAlbums($query){ - $sql = "SELECT album.id, album.name, album.year, artist.name as artistName, genre.name as genreName, cover.jpeg + $sql = "SELECT album.id, album.name, album.year, artist.id as artist_id, artist.name as artistName, genre.name as genreName, cover.jpeg FROM album JOIN artist ON album.artistid = artist.id JOIN genre ON album.genreid = genre.id @@ -32,6 +32,7 @@ class Search_model extends CI_Model { $query = $this->db->query($sql, array('%' . $query . '%')); return $query->result(); } + public function searchGenres($query){ $sql = "SELECT id, name FROM genre WHERE name LIKE ? ORDER BY name ASC"; @@ -45,3 +46,4 @@ class Search_model extends CI_Model { return $query->result(); } } +?> diff --git a/CodeIgniter-3.1.13/application/views/search_results.php b/CodeIgniter-3.1.13/application/views/search_results.php index cb4179a..13b6f48 100644 --- a/CodeIgniter-3.1.13/application/views/search_results.php +++ b/CodeIgniter-3.1.13/application/views/search_results.php @@ -1,72 +1,76 @@ -
Aucun résultat trouvé.
- + +Aucun résultat trouvé.
+