Home > Backend Development > PHP Tutorial > Detailed explanation of page method tutorial in ThinkPHP CURD method

Detailed explanation of page method tutorial in ThinkPHP CURD method

WBOY
Release: 2016-07-25 08:53:13
Original
977 people have browsed it
  1. $Article = M('Article');
  2. $Article->limit('0,10')->select(); // Query the first page of data
  3. $Article->limit ('10,10')->select(); // Query the second page of data
Copy code

Although the limit parameter of each page can be automatically calculated by using the paging class Page in the extended class library, But if you want to write it yourself, it will be more laborious. If you use the page method to write it, it will be much simpler, for example:

  1. $Article = M('Article');
  2. $Article->page('1,10')->select(); // Query the first page of data
  3. $Article-> page('2,10')->select(); // Query the second page of data
Copy code

Obviously, using the page method you do not need to calculate the starting position of each paged data, It will be automatically calculated internally in the page method. Since version 3.1, the page method also supports two parameters, for example:

  1. $Article->page(1,10)->select();
  2. and
  3. $Article->page('1,10')->select();
Copy code

equivalent. The page method can also be used in conjunction with the limit method, for example:

  1. $Article->limit(25)->page(3)->select();
Copy code

When the page method only has one value passed in, it means the first Several pages, and the limit method is used to set the number displayed on each page, that is, the above writing method is equivalent to:

  1. $Article->page('3,25')->select();
Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template