(编辑:jimmy 日期: 2024/11/20 浏览:2)
控制器中方法:
public function actiontindex(){ $user = Yii::app()->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, )); }
视图中显示为:
第一部分为查询的结果显示:
<table class="table table-bordered"> <thead> <tr> <th class="per10">公文类型</th> <th class="per50">公文标题</th> <th class="per15">当前步骤</th> <th class="per15">日期</th> </tr> </thead> <tbody> <"Y-m-d H:i:s",$v['create_time']) "htmlcode"><"class"=>"pagination"), 'selectedPageCssClass'=>"active" ) ); ?>以上所述是小编给大家介绍的Yii1.1中通过Sql查询进行的分页操作,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!