ThinkPHP has a variable where condition paging instance. thinkphpwhere_PHP tutorial

Source: Internet
Author: User
ThinkPHP has a variable where condition paging instance, thinkphpwhere. ThinkPHP has a variable where condition paging instance. thinkphpwhere this article describes how ThinkPHP has a variable where condition paging implementation method. Share it with you for your reference. Main functions: ThinkPHP has a variable where condition paging instance, thinkphpwhere

This article describes how ThinkPHP implements where conditional paging with variables. Share it with you for your reference.

The main function code is as follows:

The code is as follows:


$ Form = D ('announcement ');
Import ("ORG. Util. Page ");
$ Count = $ Form-> count (); // The total number of computations.
$ P = new Page ($ count, 5 );
$ Map = array (); // use an index array or object as the query condition. the condition effects of the object method and the array method are the same and can be exchanged.
$ Map ['User _ id'] = $ _ SESSION ['loginuserid']; //
$ List = $ Form-> limit ($ p-> firstRow. ','. $ p-> listRows)-> order ('announcement _ id desc ')-> where ($ map)-> findAll (); // use the where statement in paging statement writing directly
// Dump ($ Form-> getLastSql (); // Print the SQL statement
$ Page = $ p-> show (); // page ing

I hope this article will help you with PHP programming.


When thinkphp is paging, how can we get the transfer variable of the next page on the previous page? I don't want to use the original paging effect to attach the above and next pages to the image.

Public function index () {// you can change the icon style to $ user = M ('user'); import ('org. util. page '); $ count = $ user-> count (); $ listRows = 5; $ page = new Page ($ count, $ listRows ); $ list = $ user-> limit ("{$ page-> firstRow}, {$ page-> listRows}")-> select (); $ page-> setConfig ('prev', ''); // Previous page $ page-> setConfig ('next ',''); // next page // $ page-> setConfig ('first ', ''); // $ page-> setConfig ('last ',''); $ page-> setConfig ('theme ',' % upPage % downPage % '); // only show the upper and lower page options $ this-> assign ('page ', $ page-> show (); $ this-> assign ('list', $ list); $ this-> display ();}

In ThinkPHP, my search criteria are displayed on the page. The result is correct, but the result of clicking the next page or the link on the page is incorrect.

If you copy the code directly in the tp manual, no error will occur.

Examples in this article describes how ThinkPHP implements where conditional paging with variables. Share it with you for your reference. Main functions...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.