Paging solution of ZenTaoPHP framework

Source: Internet
Author: User
The ZentaoPHP framework provides the built-in paging function. Paging is a common problem for database-based applications. Take the query user list as an example to create a user module in the application. in the control file, define a list method to complete paging... "> <LINKhref =" http://www.php100.com//statics/s

 

The ZentaoPHP framework provides the built-in paging function. Paging is a common problem for database-based applications. Take the query user list as an example to create a user module in the application. in the control file, define a list method to complete the paging function:

1. the list method in control accepts three parameters: recTotal, recPerPage, pageID, and variable name.

 

2. define the getList method in model. the parameter is pager.

 

3. call $ pager-> get () in control to obtain the paging link and assign it to the template for display.

$ This-> assign ('pager', $ page-> get ());

Then, in the template, simply display $ pager.

In the paging process, the problem to be solved is the calculation of the total number of records. This function is built in dao. When paging is called for the first time, if the recTotal variable is empty, dao will automatically use the condition section in the query statement as the new query statement to obtain the value of count, and then generate the limit statement. In the subsequent links, the recTotal parameter will be written, so you do not need to query the database any more.

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.