分页的2种方式

 
第一种 自己算~
//算出一共有多少页
// $dataCount = Db::table('cz_staff')->where($map)->where('staff_status', 'in', '1,2,3,8')->where('isdelete', 0)->count('sid');
// //dump($dataCount);exit;
// //一共有多少页
// $pagemax = ceil($dataCount / $pagesize);
// $respone['total'] = $dataCount;
// $respone['pagesize'] = $pagemax;
 
 
第二种  用tp5自带的方法
 
$rel = db::name("staff")->where($map)->where('staff_status','in','1,2,3,8')->where('isdelete',0)
->paginate(10,false,['type'=>'Ajaxbootstrap']);

if($rel->isEmpty()){
return json_encode(['code' => 201, 'message' => '没有相关数据', 'data' => '']);
}
 
$page = $rel->render();
posted @ 2018-06-06 08:44  天梯小蔡  阅读(121)  评论(0)    收藏  举报