Page method of ThinkPHPCURD _ php instance

Source: Internet
Author: User
The page method is a user-friendly operation method completely created for paging query. This article mainly introduces the page method of the ThinkPHPCURD method, if you need it, you can refer to the page method of the ThinkPHP CURD method. it is also one of the methods for model coherent operations. it is a user-friendly operation method born completely for paging queries.
Usage

We have previously analyzed the use of the limit method for paging queries, while the page method is more user-friendly for paging queries. let's take the article list paging as an example, if the limit method is used, we need to query the first and second pages (assuming we output 10 pieces of data per page) as follows:

$ Article = M ('article'); $ Article-> limit ('0, 10')-> select (); // query the first page of Data $ Article-> limit ('10, 10')-> select (); // query the second page of data

Although the pagination Page in the extended class library can automatically calculate the limit parameter for each page, it is much harder to write it by yourself. if you use the Page method to write it, it is much easier, for example:

$ Article = M ('article'); $ Article-> page ('1, 10')-> select (); // query the first page of Data $ Article-> page ('2, 10')-> select (); // query the second page of data

Obviously,Using the page method, you do not need to calculate the start position of each page data. the page method automatically calculates the start position.

Since version 3.1, the page method also supports writing two parameters.For example:

$Article->page(1,10)->select();

And

$Article->page('1,10')->select();

Equivalent.

The page method can also be used with the limit method.For example:

$Article->limit(25)->page(3)->select();

WhenThe page method indicates the page number when only one value is input.The limit method is used to set the number of entries displayed on each page, that is, the preceding statement is equivalent:

$Article->page('3,25')->select();

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.