《PHP实战:Yii1.1中通过Sql查询进行的分页操作方法》要点:
本文介绍了PHP实战:Yii1.1中通过Sql查询进行的分页操作方法,希望对您有用。如果有疑问,可以联系我们。
相关主题:YII框架
控制器中方法:PHP实战
- 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,
- ));
- }
视图中显示为:PHP实战
第一部分为查询的结果显示:PHP实战
- <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>
- <?php if (isset($bonus)):?>
- <?php foreach ($bonus as $key=>$ad): ?>
- <tr>
- <td><?=$ad['typeName'] ?></td>
- <td><?=$ad['doc_title'] ?></td>
- <td><?=$ad['taskname'] ?></td>
- <td><?=date("Y-m-d H:i:s",$v['create_time']) ?></td>
- </tr>
- <?php endforeach; ?>
- <?php endif; ?>
- </tbody>
- </table>
第二部分为分页的显示:PHP实战
转载请注明本页网址:
http://www.vephp.com/jiaocheng/1372.html