方法一:
public function show_cate(){ $category_name = array(
'1' => '政法综治前沿',
'2' => '政策法规',
'3' => '平安建设',
'4' => '通知公告',
'5' => '理论研讨',
'6' => '本地动态',
'7' => '队伍建设',
);
$category_id = I('get.category_id');
$model = M('zx_article');
//计算要显示的总数据条数
$count = $model->where('category_id ='.$category_id)->order('article_id desc')->count();
//实例化Page类,传入总条数和每页要显示的条数
$page = new \Think\Page($count,2);
//使用limit函数指定查询和操作的数量
$data = $model->where('category_id ='.$category_id)->order('article_id desc')->limit($page->firstRow.','.$page->listRows)->select();
//传数据给模板
$this->assign('data',$data);
//调用Page类的show()函数
$this->assign('page',$page->show());
$this->assign('name',$category_name[$category_id]);
$this->display();
}