Thinkphp keeps query conditions unchanged by page. This post was last edited by cffall in the 2013-04-0712: 40: 30 Manual: import (ORG. util. page); & nbsp; import pagination class $ mapcount & nbsp; $ User-& gt; in wher thinkphp, the query conditions remain unchanged by page
This post was last edited by cffall at 12:40:30
In the manual:
Import ('org. Util. page'); // import the paging class
$ Mapcount = $ User-> where ($ map)-> count (); // query the total number of records meeting the requirements
$ Page = new Page ($ count, 25); // The total number of incoming records and the number of records displayed on each Page are instantiated in the paging class.
// Ensure the query conditions during paging jump
Foreach ($ map as $ key => $ val ){
$ Page-> parameter. = "$ key =". urlencode ($ val ).'&';
}
$ Show = $ Page-> show (); // display the output by Page
Here, my query conditions use in
$ Map ['code'] = array ('in', $ array );
When the second page is clicked, the query condition is unsuccessful. Cannot I use in here?
Php paging
------ Solution --------------------
I also encountered this problem and found a solution.
Import ('org. Util. page'); // import the paging class
$ Count = $ res-> where ($ sear)-> count (); // query the number of data entries
$ Page = new Page ($ count, 2); // instantiate the paging function
// Ensure the query conditions during paging jump
Foreach ($ sear as $ key => $ val ){
If (! Is_array ($ val )){
$ Page-> parameter. = "$ key =". urlencode ($ val). "&"; // assign a value to Page
}
}
$ Show = $ Page-> show (); // display the output by Page
A judgment is added here.
------ Solution --------------------
// Query
Public function search (){
$ Res = D ('info ');
$ Name = $ _ REQUEST ['name'];
$ Sear ['name'] = array ('like', '%'. $ name. '% ');
Import ('org. Util. page'); // import the paging class
$ Count = $ res-> where ($ sear)-> count (); // query the number of data entries
$ Page = new Page ($ count, 2); // instantiate the paging function
// Ensure the query conditions during paging jump
Foreach ($ name as $ key => $ val ){
$ Page-> parameter. = "$ key =". urlencode ($ val). "&"; // assign a value to Page
}
$ Show = $ Page-> show (); // display the output by Page
This is the code used to query the pages. you can check it out, but the code just sent does not comply with the rules.
This is my summary document: http://blog.sina.com.cn/s/blog_80742e010101acfq.html.