Thinkphp-php Tutorial

Source: Internet
Author: User
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.

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.