use Think\Page;
$pageCount = I('get.size',20); //每页20条
$condition = array();
$count = $model->where($condition)->count();
$Page = new Page($count, $pageCount);
$show = $Page->show();
$objs = $model->where($condition)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
$this->page = $show;
$this->obj = $bjs;
本文介绍了一种使用ThinkPHP框架进行分页查询的方法。通过设置每页显示的数据数量,并利用模型类的where方法构建查询条件,实现了对数据库记录的高效分页展示。同时,文章还展示了如何对查询结果进行排序及限制返回的数据量。
588

被折叠的 条评论
为什么被折叠?



