Home >Backend Development >PHP Tutorial >How to implement simple paging in Yii

How to implement simple paging in Yii

WBOY
WBOYOriginal
2016-07-29 08:51:35959browse

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>
<&#63;php foreach($models as $model): &#63;>
 <li><&#63;php echo $model->title;?></li>
<&#63;php endforeach; &#63;>
</ul>
<&#63;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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn