Home >Backend Development >PHP Tutorial >How to implement simple paging in Yii
The example in this article describes how to implement simple paging in Yii. Share it with everyone for your reference, the details are as follows:
yii paging method
function actionPage(){ $criteria=new CDbCriteria(); $count=Archives::model()->count($criteria); $pages=new CPagination($count); // results per page $pages->pageSize=10; $pages->applyLimit($criteria); $models=Archives::model()->findAll($criteria); $this->render('Archives', array( 'models' => $models, 'pages' => $pages )); }
view method
<ul> <?php foreach($models as $model): ?> <li><?php echo $model->title;?></li> <?php endforeach; ?> </ul> <?php $this->widget('CLinkPager', array( 'pages' => $pages, 'header'=>'', 'prevPageLabel'=>'上一页', 'nextPageLabel'=>'下一页', 'cssFile'=>'css/cc/css.css', )) ?>
Readers who are interested in more Yii-related content can check out this site's special topic: "Introduction to Yii Framework and Summary of Commonly Used Techniques", "Summary of PHP Excellent Development Framework", "Basic Tutorial for Getting Started with Smarty Templates", "Summary of PHP Date and Time Usage", "Introduction Tutorial on PHP Object-Oriented Programming", "Summary of PHP String Usage" , "Introduction to php+mysql database operation tutorial" and "Summary of common php database operation skills"
I hope this article will be helpful to everyone's PHP program design based on the Yii framework.
The above introduces the method of implementing simple paging in Yii, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.