Combine the php paging class with the YII Framework and change the style pagination class http://blog.csdn.net/buyingfei8888/article/details/40260127 as needed
The file name of the paging class in the component must be consistent with that of the component.
Where is the component loaded? In the main configuration file
The implementation of paging effect is also divided into four steps:
Controller:
Function actionShow1 () {$ good_model = Goods: model (); $ good_info = $ good_model-> findAll (); // set the total number and displayed quantity per page $ cnt = $ good_model-> count (); $ per = 6; // 1 instantiate object $ page = new Pagination ($ cnt, $ per); // 2 re-assemble the SQL statement $ SQL = "select * from {goods} $ page-> limit "; $ good_info = $ good_model-> findAllBySql ($ SQL); // 3 display the paging list $ page_list = $ page-> fpage (array (, 7 )); // echo $ page_list; // 4 divide it
Configuration template $ this-> renderPartial ('show', array ('goods _ infos '=> $ good_info, 'page _ list' => $ page_list ));}Display the following code in the template (where pagination is required)
This is so casual.
Effect:
If you want to display more results, change the controller above.
// 3 display the page List // $ page_list = $ page-> fpage (array (3, 4, 5, 6, 7); $ page_list = $ page-> fpage ();
Effect
For Mao, see the original code of the paging class: