This article mainly introduces the where condition paging method of ThinkPHP with variables. The example describes ThinkPHP's conditional query and paging skills, which has some reference value. If you need ThinkPHP, you can refer
This article mainly introduces the where condition paging method of ThinkPHP with variables. The example describes ThinkPHP's conditional query and paging skills, which has some reference value. If you need ThinkPHP, you can refer
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.
,