Codeigniter分页不按预期工作

时间:2014-03-15 01:31:38

标签: php codeigniter pagination

我无法让分页类与CodeIgniter一起工作。以下是代码和输出的片段

function detailed_sales($start_date, $end_date, $sale_type, $export_excel=0, $offset = 0)
{               
    $this->check_action_permission('view_sales');
    $start_date=rawurldecode($start_date);
    $end_date=rawurldecode($end_date);

    $this->load->model('reports/Detailed_sales');
    $model = $this->Detailed_sales;
    $model->setParams(array('start_date'=>$start_date, 'end_date'=>$end_date, 'sale_type' => $sale_type, 'offset' => $offset));

    $this->Sale->create_sales_items_temp_table(array('start_date'=>$start_date, 'end_date'=>$end_date, 'sale_type' => $sale_type));

    $config['base_url'] = site_url("reports/detailed_sales/".rawurlencode($start_date).'/'.rawurlencode($end_date)."/$sale_type/$export_excel");
    $config['total_rows'] = $model->get_total_rows();
    $config['per_page'] = $this->config->item('number_of_items_per_page') ? (int)$this->config->item('number_of_items_per_page') : 20; 

...
}

这是$ config示例输出:

array(3) { 
    ["base_url"]=> string(132) "http://localhost/phppos/PHP-Point-Of-Sale/index.php/reports/detailed_sales/2014-03-08%2000%3A00%3A00/2014-03-14%2023%3A59%3A59/all/0" 
    ["total_rows"]=> int(46) 
    ["per_page"]=> int(20) 
}

分页结果(请注意,即使我们在第一页,它也会选择第3页)。

Pagination

我做错了什么?

0 个答案:

没有答案