Paging is implemented under the framework of thinkphp. The company's website is based on the thinkphp framework, has been heard thinkphp name, finally have the opportunity to combat. Thinkphp is an MVC architecture, and MVC is no stranger to any iters, model-View-controller. He separates the logic and the data, with a lot less tedious process. In fact, in the official information has been described in detail how to paging, Portal: Http://document.thinkphp.cn/manual_3_2.html#data_page
However, it does not apply to the data has been removed from the DB, and converted to an array of cases, I contacted PHP uttered 2 months, contact thinkphp 3 weeks. Before spending a lot of time on official documents, to be familiar with thinkphp. It's ax. The official documentation is described here as a comparison:
(Only the first method on the document): using the Page class and the Limit method, the code is as follows:
= M (' User ');=->where (' Status=1 ')-> (); = \think\page (,25); = ->show (); = ->where (' Status=1 ' ->order (' Create_time ')->limit (->firstrow. ', '. ->listrows)->->assign (' list ', ); ->assign (' page ', ); ->display (); /span>
< span="">
< span="">
PHP's own function array_slice () is used. Definition here: http://www.php.net/manual/en/function.array-slice.php
is actually the array version of the Limit method. Well, the tools have been found, and the implementation is easy. Directly on the code:
= = ->getnodelists (-> = ([' data '
= Page (,10
= ([' data '), Span $p span>->firstrow,-> = ->< span Show (); Span>->assign (' page ',
->assign (' Nodes ',
->
< span="">
The 3rd line Getnodelists method extracts the data from the database and assigns it to the array nodelist.
Line 5th Count counts the number of elements in the array.
6th behavior the page class passed in parameters.
The Array_slice function in line 7th replaces the limit method. Same principle.
The 9th line assigns a value to the template using the Assign method. Definition here: http://document.thinkphp.cn/manual_3_2.html#assign
The 10th line is the same.
The code in view:
= "Page-list" >< span="">< span="">< span="">
< span="">
< span="">< span="">< span="">< span="">< span="">< span="">' Header ' = ' total%total_row% ', ' prev ' = ' prev ', ' next ' = ' next ', ' first ' = ' page ', ' last ' = ' ...% Total_page% ', ' theme ' = '%first%%up_page%%link_page%%down_page% ',
< span="">
http://www.bkjia.com/PHPjc/754073.html www.bkjia.com true http://www.bkjia.com/PHPjc/754073.html techarticle paging is implemented under the framework of thinkphp. The company's website is based on the thinkphp framework, has been heard thinkphp name, finally have the opportunity to combat. Thinkphp is the MVC architecture, MVC for any ITER ...