我现在拥有的就像 100 个 div 样式为连续 4 个,想要为其添加分页,并且我成功使用了以下代码:
public function func() {
$this->load->library('pagination');
$this->load->database('default');
$this->load->model('s_model');
$data['all_rows_s'] = $this->s_model->count_all_s();
$data['$total_s'] = $config['total_s'] = $this->s_model->count_all_ss();
$config['base_url'] = 'http://example.com/display/s/';
$config['total_rows'] = $data['all_rows_s'];
$config['per_page'] = 12;
$config['num_links'] = 5;
$config['full_tag_open'] = '<div class="page_row">';
$config['full_tag_close'] = '</div>';
$data['row'] = $this->db->get('s_data',$config['per_page'], $this->uri->segment(3))->result();
$this->pagination->initialize($config);
$this->template->set_theme(Settings_model::$db_config['active_theme']);
$this->template->set_layout('main');
$this->template->title($this->lang->line('s'));
$this->process_partial('header', '/header');
$this->process_partial('footer', '/footer');
$this->process_template_build('s_view', $data);
}
但是,这是有效的,因为没有表,因为这条线:
$data['row'] = $this->db->get('s_data',$config['per_page'], $this->uri->segment(3))->result();
但是我需要在其中添加更多过滤器,例如order by id
并且where date > NOW()
,这怎么可能呢?我可以替换这个 get 并且代码仍然可以工作,并且视图再次没有表,divs
位于foreach
.
谢谢!