Home > Backend Development > PHP Tutorial > How to implement paging in YII, how to implement paging in YII_PHP tutorial

How to implement paging in YII, how to implement paging in YII_PHP tutorial

WBOY
Release: 2016-07-13 10:23:20
Original
1022 people have browsed it

YII implements paging method, YII implements paging method

This article briefly describes the method of paging in Yii with example code for reference by friends who are learning Yii. The specific code is as follows:

1. Controller part code:

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)); 
} 
Copy after login

2. View part code:

<&#63;php 
foreach($list as $o) 
{ 
echo $o->username.'<br/>'; 
echo $o->id.'<br/>'; 
} 
$this->widget('CLinkPager',array( 
'header'=>'', 
'firstPageLabel' => '首页', 
'lastPageLabel' => '末页', 
'prevPageLabel' => '上一页', 
'nextPageLabel' => '下一页', 
'pages' => $pages, 
'maxButtonCount'=>13 
) 
); 
&#63;>
Copy after login

Yii paging problem, use it urgently

SQL uses limit and offset. Use $pages = new CPagination ();
for pagination

Teach how to implement three public methods in YII

You can first read the basic tutorial and try to use the AR model. In this case, you can first build a posts table to store the public part of the publishing information, so that all resources can be in a basic model and can be generated using GII Model and CURD all the codes, and then set a resource type according to the posts, and use the id to associate to different resource tables. As for the tags, you can set up another table and associate it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/840743.htmlTechArticleHow to implement paging in YII, how to implement paging in YII This article briefly describes the method of implementing paging in yii with example code, for For reference by friends who are learning Yii, the specific code is as follows: 1. Controller part code:...
Related labels:
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