Combine get_where and limit in active codeigniter record

I'm a little confused here.

I have such a modal view:

public function selectRequestPerUser($nama_user, $start_row, $limit) { $query = $this->db->get_where('tbl_requestfix', array('nama_user' => $nama_user), $start_row, $limit); return $query->result_array(); } 

So, I use this modal way to create pagination in CI as follows:

 $nama = $this->session->userdata('nama'); $start_row = $this->uri->segment(2); $per_page = 3; if(trim($start_row) == ''){ $start_row = 0; }; $this->load->library('pagination'); $config['base_url'] = base_url().'control_closing/'; $config['total_rows'] = $total_rows; $config['per_page'] = $per_page; $this->pagination->initialize($config); $data['pagination'] = $this->pagination->create_links(); $request = $this->model_request->selectRequestPerUser($nama, $start_row, $per_page); $data['data_request'] = $request; $this->load->view('view_closing', $data); 

just:

 <?php echo pagination ?> 

Just give me a blank page. I think there is a problem in my modal get_where. Can anybody help?

+5
source share
1 answer

The syntax for get_where() is

 $query = $this->db->get_where('mytable', array('id' => $id), $limit, $offset); 

You need to change this line in your model (change $start_row and $limit ) for it to work,

 $query = $this->db->get_where('tbl_requestfix', array('nama_user' => $nama_user), $limit, $start_row); 
+2
source

All Articles