我想在代码点火器中创建分页。一切正常,但 $ limit和$ id 无效,这就是为什么我的观点不会转到下一页。我尝试了更多的方式,但没有达到我的目标。请帮忙。
模型
public function display_testSuiteRun($limit, $id) {
$sql = "
SELECT tsr.id as id, tsr.name as name, ts.test_suite_name as test_suite_name, GROUP_CONCAT(u.name SEPARATOR '\n <br>') as tester_name FROM test_suite_run tsr, users u, test_suite ts
WHERE FIND_IN_SET(u.id, tsr.tester_id) AND ts.id = tsr.test_suite_id
GROUP BY tsr.id ORDER BY tsr.id DESC LIMIT $limit, $id";
$query = $this->db->query($sql);
return $query->result();
}
控制器
public function display_test_suite_run_list_with_pagination() {
$this->load->library('pagination');
$config = array();
$config["base_url"] = base_url() . "index.php/tester/display_test_suite_run_list_with_pagination";
$total_row = $this->model_tester_test->record_count();
$config["total_rows"] = $data["total_data_stored"] = $total_row;
$config["per_page"] = 5;
$config['use_page_numbers'] = false;
$config['num_links'] = $total_row;
$config['cur_tag_open'] = ' <a class="current">';
$config['cur_tag_close'] = '</a>';
$config['next_link'] = 'Next';
$config['prev_link'] = 'Previous';
$this->load->library('pagination');
$this->pagination->initialize($config);
if ($this->uri->segment(3)) {
$page = ($this->uri->segment(3));
} else {
$page = 0;
}
$data["value_of_test_suite_run"] = $this->model_tester_test->display_testSuiteRun($config["per_page"], $page);
$str_links = $this->pagination->create_links();
$data["links"] = explode(' ', $str_links);
//this is for dropdown list search//this is for dropdown list search
$data['get_testSuiteRunforSearchDropdown'] = $this->model_tester_test->get_testSuiteRunforSearchDropdown();
// View data according to array.
$this->layout->view('tester/view_test_suite_run_display', $data);
}
答案 0 :(得分:1)
改变它
$this->model_tester_test->display_testSuiteRun($config["per_page"], $page);
如下
$this->model_tester_test->display_testSuiteRun($page, $config["per_page"]);
因为您正在使用原始SQL查询,其中$limit
用作偏移量,而$id
是要显示的行数