第一种 自己算~
- // 算出一共有多少页
- // $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();
来源: http://www.bubuko.com/infodetail-2632783.html