2013-06-04 56 views
1

我有我的分頁笨:分頁編輯查詢

控制器:

$this->load->library('pagination', TRUE); 
$conf['base_url'] = "http://localhost/projecto/index.php/produto_serv_c/list_produto_serv"; 
$conf['per_page'] = 10;    
$conf['num_links'] = 5; 
$conf['total_rows'] = $this->get_list_m->get_prod_serv()->num_rows(); 

$this->pagination->initialize($conf); 
$cenas = $this->get_list_m->get_prod_serv()->result_array(); 

$data['query'] = $this->db->get("produto_servico_tbl", $conf['per_page'], $this->uri->segment(3)); 

買,我想這樣做查詢:

型號:

public function get_prod_serv(){ 
    $this->db->from('produto_servico_tbl'); 
    $this->db->where('id_empresa', $this->session->userdata('id_empresa')); 
    $this->db->order_by('referencia', 'asc'); 
    $this->db->having('id_empresa', $this->session->userdata('id_empresa')); 

    $query = $this->db->get(); 
    return $query; 
} 

我如何c更改分頁查詢?

回答

1

你忘了把限制在你的代碼多數民衆贊成Ÿ分頁不工作

public function get_prod_serv($number, $start){ 
    $this->db->from('produto_servico_tbl'); 
    $this->db->where('id_empresa', $this->session->userdata('id_empresa')); 
    $this->db->limit($number, $start); 
    $this->db->order_by('referencia', 'asc'); 
    $this->db->having('id_empresa', $this->session->userdata('id_empresa')); 

    $query = $this->db->get(); 
    return $query; 
}