控制器中方法:
user;
$id = $user->id;
$connection=Yii::app()->db;
$sql= "SQL查询语句";
$command = $connection->createCommand($sql)->queryAll();
$pages = new CPagination(count($command));
$list = $connection->createCommand($sql." limit ".$pages->limit." offset ".$pages->offset."")->queryAll();
$this->render('index',array(
'bonus' => $list,'pages' => $pages,));
}
视图中显示为:
PHP;">
标题 | ||
---|---|---|
PHP;">
widget('CLinkPager',array(
'header'=>'','firstPageLabel' => '首页','lastPageLabel' => '末页','prevPageLabel' => '上一页','nextPageLabel' => '下一页','maxButtonCount'=>8,'cssFile'=>false,'htmlOptions' =>array("class"=>"pagination"),'selectedPageCssClass'=>"active"
)
);
?>
以上所述是小编给大家介绍的Yii1.1中通过SQL查询进行的分页操作,希望对大家有所帮助。程序员遇到问题都会上(编程之家jb51.cc)查找问题解答方法!如果觉得站点还不错,随手转发给程序员朋友一下!
原文链接:https://www.f2er.com/php/17762.html