Home  >  Article  >  PHP Framework  >  Incredible demand: TP5 native sql paging can solve it!

Incredible demand: TP5 native sql paging can solve it!

藏色散人
藏色散人forward
2021-10-14 16:18:591907browse

The followingthinkphp frameworkThe tutorial column will introduce to you the native sql paging issues of thinkphp5. I hope it will be helpful to friends in need!

Incredible demand: TP5 native sql paging can solve it!

Incredible demand: TP5 native sql paging can solve it!

thinkphp5 native sql paging to solve abnormal customer needs

I am developing a home decoration website recently, and there are a lot of customer needs. . . .

You need to use native sql to solve it.

tp5’s order does not support pornographic operations and will be filtered out by default. . . .

    //use think\paginator\driver\Bootstrap; 记得引入
    
    $pageSize=8;//每页8条
    
    $currPage=input('page',1);
    
    $list = Db::query("select * from osc_sms order by id limit ?,?",[($currPage-1)*$pageSize,$pageSize]);
    
    $total = Db::query("select count(*) cnt from osc_sms")[0]['cnt'];
    
    $pagernator = Bootstrap::make($list,$pageSize,$currPage,$total,false,['path'=>Bootstrap::getCurrentPath(),'query'=>request()->param()]);
    
    $page = $pagernator->render();

Recommended: "The latest 10 thinkphp video tutorials"

The above is the detailed content of Incredible demand: TP5 native sql paging can solve it!. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete