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

Incredible demand: TP5 native sql paging can solve it!

藏色散人
Release: 2021-10-14 16:18:59
forward
1946 people have browsed it

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();
Copy after login

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!

Related labels:
php
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template