Heim > Artikel > Backend-Entwicklung > yii CLinkPager 分页 没有生效
action 代码
$sql='SELECT * FROM '.ParkRolePage::model()->tableName().' order by rolepage_id limit 0,5 '; //$model= ParkRolePage()::model(); $model=$this->db()->createCommand($sql)->queryAll(); $pages = new CPagination(ParkRolePage::model()->count()); $pages->pageSize=10; //die(); //if(isset($_GET['ParkRolePage'])) //$model->attributes=$_GET['ParkRolePage']; $this->controller->render('admin',array( 'model'=>$model, 'pages'=>$pages, ));
<table ><tr><td>关系id</td><td>角色id</td><td>页面访问代码</td><td colspan="3">操作选项</td></tr><?php foreach($model as $k=>$v): ?><tr><td><?php echo $v['rolepage_id']?></td><td><?php echo $v['role_id']?></td><td><?php echo $v['rolepage_con']?></td><td><a href="<?php echo $this->createUrl('/parkrolepage/view',array('id'=>$v['rolepage_id'])) ?>">查看</a></td><td><a href="<?php echo $this->createUrl('/parkrolepage/update',array('id'=>$v['rolepage_id']))?>">修改</a></td><td><a href="<?php echo $this->createUrl('/parkrolepage/delete',array('id'=>$v['rolepage_id']))?>">删除</a></td></tr><?php endforeach?><td colspan="6"><?php $this->widget('CLinkPager', array( 'header'=>'翻页:', 'pages' => $pages, 'firstPageLabel'=>'首页', 'lastPageLabel' =>'末页', 'prevPageLabel'=>'前一页', 'nextPageLabel'=>'下一页', 'maxButtonCount'=>13 )) ?> </td></table>
$model=Yii::app()->db->createCommand($sql." LIMIT :offset,:limit"); $model->bindValue(':offset', $pages->currentPage*$pages->pageSize); $model->bindValue(':limit', $pages->pageSize); $model=$model->queryAll();