yii CLinkPager 分页 没有生效

WBOY
Release: 2016-06-23 14:15:23
Original
880 people have browsed it

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


view 代码

<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>
Copy after login


只有 两页 而且 点击下一页 还是 显示的上一页的内容


回复讨论(解决方案)

$model=Yii::app()->db->createCommand($sql." LIMIT :offset,:limit");    $model->bindValue(':offset', $pages->currentPage*$pages->pageSize);    $model->bindValue(':limit', $pages->pageSize);    $model=$model->queryAll();   
Copy after login


看文档

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