Home >php教程 >php手册 >YII实现分页的方法

YII实现分页的方法

WBOY
WBOYOriginal
2016-06-06 20:20:231353browse

这篇文章主要介绍了YII实现分页的方法,需要的朋友可以参考下

本文以实例代码简述了yii实现分页的方法,,供学习yii的朋友参考,具体代码如下:

1.控制器部分代码:    

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.视图部分代码:

username.'
'; echo $o->id.'
'; } $this->widget('CLinkPager',array( 'header'=>'', 'firstPageLabel' => '首页', 'lastPageLabel' => '末页', 'prevPageLabel' => '上一页', 'nextPageLabel' => '下一页', 'pages' => $pages, 'maxButtonCount'=>13 ) ); ?>

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