这样做
public function index($offset = 0)
{
$this->load->library('pagination');
$limit = 10;
$total = $this->legend_model->get_legend_count($language_id);
$config['base_url'] = base_url().'legend/index/';
$config['total_rows'] = $total;
$config['per_page'] = $limit;
$config['uri_segment'] = 3;
$config['first_link'] = '<< First';
$config['last_link'] = 'Last >>';
$config['next_link'] = 'Next ' . '>';
$config['prev_link'] = '<' . ' Previous';
$config['num_tag_open'] = '<span class="number">';
$config['num_tag_close'] = '</span>';
$config['cur_tag_open'] = '<span class="current"><a href="#">';
$config['cur_tag_close'] = '</a></span>';
$this->pagination->initialize($config);
$data['offset'] = $offset;
$data['legends'] = $this->legend_model->get_legend($language_id, $limit, $offset);
$this->template->write('title', 'Legend : Manage Legend');
$this->template->write_view('content', 'legend/index', $data);
$this->template->render();
}
在模型中
//Get legend
public function get_legend($language_id = 1, $limit = 10, $offset = 0)
{
$this->db->select('l.id,lt.title,lt.status');
$this->db->from('legends l');
$this->db->join('legend_translations lt', 'l.id = lt.legend_id');
$this->db->where('lt.language_id', $language_id);
$this->db->order_by('l.id DESC');
$this->db->limit($limit, $offset);
$legend = $this->db->get();
return $legend->result();
}