请查看名为“test”的控制器中的以下代码:
$this->load->library('pagination');
// These 3 are the minimum config that needs to be set
$config['base_url'] = base_url() . 'test/?' . http_build_query($_GET, '', '&');
$config['total_rows'] = 173;
$config['per_page'] = 20;
// This returns something like this: ?name=foo/20
// I would expect something like this: ?name=foo&per_page=20
// $config['enable_query_strings'] = TRUE;
// This retuns something like this: ?name=foo&per_page=20 (which is what I want),
// but the documentation says it should be: ?c=test&m=index&per_page=20
$config['page_query_string'] = TRUE;
$this->pagination->initialize($config);
echo $this->pagination->create_links();
然后转到:test/?name=foo
生成的分页链接看起来是正确的。当您单击链接号“2”时,您将被重定向到?name=foo&per_page=20
正确的位置。但是,创建的新分页看起来不对。它看起来像这样:(?name=foo&per_page=20&per_page=40
其中 per_page 在查询字符串中出现两次)。
这是怎么回事?