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.