The example in this article describes how Yii implements simple paging. 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 the special topics on this site: "Introduction to Yii Framework and Summary of Common Techniques", "Summary of Excellent PHP Development Framework", "Basic Tutorial for Getting Started with Smarty Templates", "php Date and Time" Usage Summary", "php object-oriented programming introductory tutorial", "php string (string) usage summary", "php mysql database operation introductory tutorial" and "php common database operation skills summary"
I hope this article will be helpful to everyone’s PHP program design based on the Yii framework.