In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use the page method of thinkphp". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use the page method of thinkphp".
In thinkphp, page method is one of the model coherent operation methods, and it is a humanized operation method for paging query. Using this method, there is no need to calculate the starting position of each paging data, the interior of this method will be calculated automatically, and the syntax is "$Article- > page (1jing10)-> select ()".
This article operating environment: Windows10 system, ThinkPHP5 version, Dell G3 computer.
What is the page method of thinkphp?
Page method is one of the coherent operation methods of the model, and it is a humanized operation method which is completely born for paging query.
Usage
We have already learned about the limit method for paging query, while the page method is a more humane method for paging query. For example, taking the article list paging as an example, if we use the limit method, 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 (' 0jue 10')-> select (); / / query the first page of data $Article- > limit ('10jue 10')-> select (); / / query the second page of data
Although you can automatically calculate the limit parameters of each page by using the paging class Page in the extended class library, it is more laborious to write it yourself, and it is much easier to write it with the page method, for example:
$Article = M ('Article'); $Article- > page (' 1Magazine 10')-> select (); / / query the first page of data $Article- > page ('2jing10')-> select (); / / query the second page of data
Obviously, with the page method, you don't need to calculate the starting position of each paged data, it is automatically calculated inside the page method.
After version 3.1, the page method also supports the writing of 2 parameters, such as:
$Article- > page (1mai 10)-> select ()
And
$Article- > page ('1mai 10')-> select ()
Equivalent.
The page method can also be used with the limit method, for example:
$Article- > limit (25)-> page (3)-> select ()
When only one value is passed in the page method, the page number is indicated, while the limit method is used to set the number of pages displayed, that is, the above writing is equivalent to:
$Article- > page ('3pr 25')-> select (); Thank you for reading, the above is the content of "how to use thinkphp's page method". After the study of this article, I believe you have a deeper understanding of how to use thinkphp's page method, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.