This article mainly introduces the where condition paging method of ThinkPHP with variables. The example describes ThinkPHP conditional query and paging techniques, which has some reference value, for more information about how ThinkPHP implements where conditional paging with variables, see the example in this article. 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.