Как мы можем добавить общее количество результатов поиска и нумерацию страниц в codeigniter.
Я хочу показать общее количество результатов поиска на странице результатов с нумерацией страниц. спасибо кто-нибудь может помочь
много пробовал, но не смог достичь.
помогите пожалуйста
Модель
function search_results($title, $params = array()){
$this->db->select("ID,section,Title,img,year,lastupdateon AS ondate,'movies/' AS dept,STATUS");
$this->db->from('movies');
$this->db->Like('Title',$title,'after');
$this->db->or_Like('year',$title,'after');
$this->db->or_Like('section',$title,'after');
$query[] = $this->db->get_compiled_select();
$this->db->select("ID,section,Title,img,year,lastupdateon AS ondate,'view/kid/' AS dept,STATUS");
$this->db->from('kids');
$this->db->Like('Title',$title,'after');
$query[] = $this->db->get_compiled_select();
$this->db->select("ID,views,Title,img,version AS year,ondate,'view/software/' AS dept,STATUS");
$this->db->from('soft');
$this->db->Like('Title',$title,'after');
$query[] = $this->db->get_compiled_select();
$this->db->select("ID,section,Title,img,'PC Game' AS year,ondate,'view/game/' AS dept,STATUS");
$this->db->from('games');
$this->db->Like('Title',$title,'after');
$query[] = $this->db->get_compiled_select();
$this->db->select("ID,season,Title,img,type AS year,lastupdatedon AS ondate,'view/tvshow/' AS dept,STATUS");
$this->db->from('tvshows');
$this->db->Like('Title',$title,'after');
$query[] = $this->db->get_compiled_select();
$union_query = join(' UNION ALL ',$query); // I use UNION ALL
$union_query .= " ORDER BY ondate DESC";
if(array_key_exists("returnType",$params) && $params['returnType'] == 'count'){
$result = $this->$union_query->num_rows();
}
$query = $this->db->query($union_query);
//echo $query->num_rows();
return $query->result();
}
Контроллер
function search(){
$title=$this->input->get('Title');
$data['data']=$this->blog_model->search_results($title);
$config['per_page']= 10;
$config['uri_segment'] = 4;
$config['base_url'] = site_url('/index.php/tutorial/search').'/';
$this->data['per_page_display'] = $config['per_page'];
$conditions['returnType'] = 'count';
$totalRec = $this->blog_model->search_results($conditions);
$config['total_rows'] = count($conditions);
$this->data['totalcount'] = $config['total_rows'];
$this->pagination->initialize($config);
$this->data['paginglinks'] = $this->pagination->create_links();
$this->data['per_page'] = $this->uri->segment(4);
$this->data['page'] = $offset;
$this->load->view('search_view',$data);
}