Home >Backend Development >PHP Tutorial >YII paging method (controller and view paging)

YII paging method (controller and view paging)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 08:53:01961browse
  1. public function actionTest()
  2. {
  3. $criteria=new CDbCriteria;
  4. $criteria->order='id DESC';
  5. $count=User::model()->count($criteria) ;
  6. $pager=new CPagination($count);
  7. $pager->pageSize=10;
  8. $pager->applyLimit($criteria);
  9. $userList=User::model()->findAll($ criteria);
  10. $this->render('test',array('list'=>$userList,'pages'=>$pager));
  11. } // bbs.it-home.org
Copy code

2, view part code:

  1. foreach($list as $o)
  2. {
  3. echo $o->username.'
    ';
  4. echo $o->id.'
    ';
  5. }
  6. $this->widget('CLinkPager',array(
  7. 'header'=>'',
  8. 'firstPageLabel' => 'Home',
  9. 'lastPageLabel' => 'Last page' ,
  10. 'prevPageLabel' => 'Previous page',
  11. 'nextPageLabel' => 'Next page',
  12. 'pages' => $pages,
  13. 'maxButtonCount'=>13
  14. )
  15. );
Copy code


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