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...