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. '<br/>'; echo $ o-> id. '<br/>';} $ 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.