我目前是 CodeIgniter 的新手,并尝试使用 codeigniter 的分页类添加分页。
控制器:
public function view_emp(){
$data['design'] = 'emp_view';
$this->load->model('user_model');
$data = $this->user_model->getall();
$total_rows = $data->num_rows();
$config['base_url'] = base_url() . 'main';
$config['total_rows'] = $total_rows;
$config['per_page'] = 10;
$this->pagination->initialize($config);
$this->view_data['pagination'] = $this->pagination->create_links();
$this->view_data['result'] = $data;
if($this->session->userdata('is_logged_in')){
$this->load->view('includes/template', $data);
}
else{
redirect('main/restricted');
}
模型:
public function getall(){
$query = $this->db->get('another_user');
return $query->result();
}
public function getall_limit($start_row, $limit){
$data = "SELECT * FROM another_user limit $start_row, $limit";
$result = $this->db->query($data);
return $result;
}
在我看来,我只是从我的控制器中呼应了 $pagination 有人可以帮我吗?我现在真的很难过。