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

YII paging method (controller and view paging)

WBOY
Release: 2016-07-25 08:53:01
Original
936 people have browsed it
  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


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template