ThinkPHP variable where condition paging instance _ php instance

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

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.