当前位置: 首页 > 后端技术 > PHP

thinkphp5原生sql分页,解决异常客户需求

时间:2023-03-29 15:15:53 PHP

最近在开发一个家装网站,有很多客户需求。...需要使用原生sql来解决。tp5的顺序不支持风骚操作,默认会过滤掉。...//使用think\paginator\driver\Bootstrap;记得引入$pageSize=8;//8itemsperpage$currPage=input('page',1);$list=Db::query("select*fromosc_smsorderbyidlimit?,?,[($currPage-1)*$pageSize,$pageSize]);$total=Db::query("selectcount(*)cntfromosc_sms")[0]['cnt'];$pagernator=Bootstrap::make($list,$pageSize,$currPage,$total,false,['path'=>Bootstrap::getCurrentPath(),'query'=>request()->param()]);$page=$pagernator->render();