Fix query 4/?
This commit is contained in:
		@@ -12,9 +12,9 @@ class Artistes extends CI_Controller {
 | 
				
			|||||||
    public function index(){
 | 
					    public function index(){
 | 
				
			||||||
        $genre = $this->input->get('genre');
 | 
					        $genre = $this->input->get('genre');
 | 
				
			||||||
        $order = $this->input->get('order');
 | 
					        $order = $this->input->get('order');
 | 
				
			||||||
		$query = $this->input->get('query');
 | 
					        $query = $this->input->get('query');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $artists = $this->model_music->getArtists($genre, $order, $query);
 | 
					        $artists = $this->model_music->getArtists($genre, $order, $query); // Pass $query
 | 
				
			||||||
        $genres = $this->model_music->researchtype();
 | 
					        $genres = $this->model_music->researchtype();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $is_logged_in = $this->session->userdata('logged_in');
 | 
					        $is_logged_in = $this->session->userdata('logged_in');
 | 
				
			||||||
@@ -26,7 +26,8 @@ class Artistes extends CI_Controller {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $this->load->view('layout/header', $data);
 | 
					        $this->load->view('layout/header', $data);
 | 
				
			||||||
        $this->load->view('layout/getter', $data);
 | 
					        $this->load->view('layout/getter', $data);
 | 
				
			||||||
        $this->load->view('artists_name', $data);
 | 
					        $this->load->view('artists_list', $data);
 | 
				
			||||||
        $this->load->view('layout/footer');
 | 
					        $this->load->view('layout/footer');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,7 +30,7 @@ class Music extends CI_Controller {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $this->load->view('layout/header', $data);
 | 
					        $this->load->view('layout/header', $data);
 | 
				
			||||||
        $this->load->view('layout/getter', $data);
 | 
					        $this->load->view('layout/getter', $data);
 | 
				
			||||||
        $this->load->view('musiques_name', $data);
 | 
					        $this->load->view('musiques_list', $data);
 | 
				
			||||||
        $this->load->view('layout/footer');
 | 
					        $this->load->view('layout/footer');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,32 +46,33 @@ class Model_music extends CI_Model {
 | 
				
			|||||||
        return $query->result();
 | 
					        return $query->result();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function getArtists($genre = '', $order = '') {
 | 
					    public function getArtists($genre = '', $order = 'asc', $query = '') {
 | 
				
			||||||
        $this->db->select('artist.name as artistName, artist.id as artistId');
 | 
					        $this->db->select('artist.name as artistName, artist.id as artistId');
 | 
				
			||||||
        $this->db->from('artist');
 | 
					        $this->db->from('artist');
 | 
				
			||||||
        $this->db->join('album', 'album.artistid = artist.id');
 | 
					        $this->db->join('album', 'album.artistid = artist.id');
 | 
				
			||||||
        $this->db->join('genre', 'genre.id = album.genreid');
 | 
					        $this->db->join('genre', 'genre.id = album.genreid');
 | 
				
			||||||
        $this->db->join('cover', 'cover.id = album.coverid');
 | 
					        $this->db->join('cover', 'cover.id = album.coverid');
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
        $this->db->distinct("artist.name");
 | 
					        $this->db->distinct("artist.name");
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
        if (!empty($genre)) {
 | 
					        if (!empty($genre)) {
 | 
				
			||||||
            $this->db->where('genre.name', $genre);
 | 
					            $this->db->where('genre.name', $genre);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
        if ($order == 'asc' || $order == 'desc') {
 | 
					        if ($order == 'asc' || $order == 'desc') {
 | 
				
			||||||
            $this->db->order_by('artist.name', $order);
 | 
					            $this->db->order_by('artist.name', $order);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
        if (!empty($query)) {
 | 
					        if (!empty($query)) {
 | 
				
			||||||
            $this->db->like('artist.name', $query);
 | 
					            $this->db->like('artist.name', $query);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
        $result = $this->db->get();
 | 
					        $result = $this->db->get();
 | 
				
			||||||
        return $result->result();
 | 
					        return $result->result();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function getMusics($genre = '', $order = '', $artist = '') {
 | 
					    public function getMusics($genre = '', $order = '', $artist = '', $query = '') {
 | 
				
			||||||
        $this->db->select('album.name, album.id, year, artist.name as artistName, genre.name as genreName, jpeg, song.name as trackName, track.id as trackId');
 | 
					        $this->db->select('album.name, album.id, year, artist.name as artistName, genre.name as genreName, jpeg, song.name as trackName, track.id as trackId');
 | 
				
			||||||
        $this->db->from('track');
 | 
					        $this->db->from('track');
 | 
				
			||||||
        $this->db->join('album', 'track.albumId = album.id');
 | 
					        $this->db->join('album', 'track.albumId = album.id');
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
<h5>Albums list</h5>
 | 
					<h5>Liste des Albums</h5>
 | 
				
			||||||
<section class="list">
 | 
					<section class="list">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<?php
 | 
					<?php
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
<h5>Artists list</h5>
 | 
					<h5>Liste des Artistes</h5>
 | 
				
			||||||
<section class="list">
 | 
					<section class="list">
 | 
				
			||||||
<?php
 | 
					<?php
 | 
				
			||||||
foreach($artists as $artist){
 | 
					foreach($artists as $artist){
 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
<h5>Musiques List</h5>
 | 
					<h5>Liste des musiques</h5>
 | 
				
			||||||
<section class="list">
 | 
					<section class="list">
 | 
				
			||||||
<?php
 | 
					<?php
 | 
				
			||||||
foreach($musics as $music){
 | 
					foreach($musics as $music){
 | 
				
			||||||
		Reference in New Issue
	
	Block a user