我想知道是否可以在分页配置文件中动态更改total_rows ,因为所有查询的total_rows可能不同。这是我的代码:
$config['base_url'] = current_url();
$config['total_rows'] = 200; //I need to change dynamically
$config['per_page'] = 20;
$config['full_tag_open'] = '<div class="pagination pagination-small pagination-centered">';
$config['full_tag_close'] = '</div>';
$config['next_link'] = '>';
$config['prev_link'] = '<';
$config['first_link'] = '';
$config['last_link'] = '';
由于
答案 0 :(得分:1)
您可以尝试这样的事情:
$count = $this->db->count_all_results( 'table_name' );
$total_rows = 4;
if ( $count > $total_rows ) {
$config['base_url'] = current_url();
$config['total_rows'] = $count; //I need to change dynamically
$config['per_page'] = 20;
$config['full_tag_open'] = '<div class="pagination pagination-small pagination-centered">';
$config['full_tag_close'] = '</div>';
$config['next_link'] = '>';
$config['prev_link'] = '<';
$config['first_link'] = '';
$config['last_link'] = '';
}