YII implements paging, and YII implements paging. YII implements paging. YII implements paging. This article describes how yii implements paging based on the instance code for your reference. the code is as follows: 1. part of the controller code: YII implements paging, and YII implements paging.
This article describes how to implement paging in yii by using the instance code 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,'pages'=>$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);?>
Yii paging problem, urgent
SQL uses limit and offset. Use $ pages = new CPagination () for paging ();
How to implement three public methods in YII
You can first take a look at the basic tutorial and try to use the AR model. in this way, you can first create a posts table to store the public part of the published information, so that all resources can be in a basic model, you can use gii to generate the model and all the code of CURD, and then set a resource type based on posts, and associate the id with different resource tables. As for the tag, you can set another table, associate with the previous one.
In the example code, this article describes how to implement paging in yii for your reference. the specific code is as follows: 1. Some controller code :...