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

How to implement simple paging in Yii, implement paging in yii_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:53:051003browse

How Yii implements simple paging, yii implements paging

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>
<&#63;php foreach($models as $model): &#63;>
 <li><&#63;php echo $model->title;&#63;></li>
<&#63;php endforeach; &#63;>
</ul>
<&#63;php $this->widget('CLinkPager', array(
  'pages' => $pages,
    'header'=>'',
    'prevPageLabel'=>'上一页',
    'nextPageLabel'=>'下一页',
    'cssFile'=>'css/cc/css.css',
)) &#63;>

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1125260.htmlTechArticleYii's method to implement simple paging, yii to implement paging. This article describes the Yii method to implement simple paging. Share it with everyone for your reference, the details are as follows: yii paging method function act...
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