This article mainly introduces how YII implements paging. if you need it, you can refer to the following example code to briefly describe how yii implements paging for your reference. the specific code is as follows:
1. Some controller code:
Public function actionTest () {$ criteria = new CDbCriteria; $ criteria-> order = 'Id desc'; $ count = User: model ()-> count ($ criteria ); $ pager = new CPagination ($ count); $ pager-> pageSize = 10; $ pager-> applyLimit ($ criteria); $ userList = User: model () -> findAll ($ criteria); $ this-> render ('test', array ('list' => $ userList, 'pag' => $ pager ));}
2. View code:
<? Php foreach ($ list as $ o) {echo $ o-> username .'
'; Echo $ o-> id .'
';} $ This-> widget ('clinkpager', array ('header' => '', 'firstpagelabel '=> 'homepage ', 'lastpagelabel '=> 'Last page', 'prevpagelabel' => 'previous page', 'nextpagelabel '=> 'next page', 'page' => $ pages, 'maxbuttoncount' => 13);?>