|
发表于 2012-2-14 23:04:06
|
显示全部楼层
Controllor:
function index($offset = ''){
// 加载分页类
$limit = 20;
$config['base_url'] = site_url('admin_user/index');
$config['total_rows'] = $this->My_a_model->count_table();
$config['per_page'] = $limit;
$config['first_link'] = '首页';
$config['prev_link'] = '上一页';
$config['next_link'] = '下一页';
$config['last_link'] = '尾页';
$config['num_links'] = 2;
$data['limit'] = $limit;
$data['offset'] = $offset+1;
$this->pagination->initialize($config);
$total = $this->My_a_model->count_table();//总页数
$current = $offset+1;//当前页
$pagination = $this->pagination->create_links();
$data['page'] = '总记录'.$total.'条记录 当前页'.$current.'/'.$total.' '. $pagination;
//$data['query'] = $this->db->get('admin_user');
$data['listQuery'] = $this->My_a_model->show_list($limit, $offset);
$data['title'] = '系统用户列表';
$this->load->view('admin/admin_user', $data);
exit();
}
model:
//查询表记录,分页类
function count_table($table = 'admin_user'){
return $this->db->count_all($table);
}
function show_list($limit, $offset, $table = 'admin_user'){
if(!$limit){
$this->db->order_by('id', 'DESC');
return $this->db->get($table, $order);
}else{
$this->db->order_by('id', 'DESC');
$this->db->limit($limit,$offset);
return $this->db->get($table, $limit, $offset);
//OR
//return $this->db->get($table);
}
}
View
<?php echo $page;?>
|
|