Codeigniter Pagination lib不起作用?

时间:2015-08-11 10:52:49

标签: php codeigniter

这是我的代码:

$this->load->library('pagination');
$config = array();
$config["base_url"] = base_url() . "Reports/payment";
$config["total_rows"] = 40/;
$config["per_page"] = 20;
$config["uri_segment"] = 3;
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data["links"] = $this->pagination->create_links();
$data['main_content'] = $this->module . '/' . $page;
$this->load->view('admin/page', $data);

这是错误字符串:

  

致命错误:在null中调用成员函数initialize()   C:\ XAMPP \ htdocs中....

到目前为止我尝试过的事情:

1.i自动加载分页库 [no-luck]

2.i在库中创建一个库并加载 [no-luck]

4.i在相同的构造函数中加载lib [no-luck]

5.i尝试使用大写Pagination [no-luck]

我不知道问题出在哪里。 我搜索很多但没有运气。 如果您需要更多信息,请告诉我

1 个答案:

答案 0 :(得分:-2)

尝试将分页库加载到自定义对象,如:

$CI = get_instance();

$CI->load->library('pagination');
$config = array();
$config["base_url"] = base_url() . "Reports/payment";
$config["total_rows"] = 40;
$config["per_page"] = 20;
$config["uri_segment"] = 3;
$CI->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data["links"] = $CI->pagination->create_links();
$data['main_content'] = $this->module . '/' . $page;
$this->load->view('admin/page', $data);