Yii1.1中通过Sql查询进行的分页操作
2017-03-15 18:02
387 查看
控制器中方法:
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> <?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 $this->widget('CLinkPager',array( 'header'=>'', 'firstPageLabel' => '首页', 'lastPageLabel' => '末页', 'prevPageLabel' => '上一页', 'nextPageLabel' => '下一页', 'pages' => $pages, 'maxButtonCount'=>8, 'c 8dbb ssFile'=>false, 'htmlOptions' =>array("class"=>"pagination"), 'selectedPageCssClass'=>"active" ) ); ?>
相关文章推荐
- Yii1.1中通过Sql查询进行的分页操作方法
- 通过存储过程进行分页查询的SQL示例
- 在SQL Server中通过SQL语句实现分页查询
- sql数据分组后进行的分页操作
- 通过SQL查询多个表的结果且分页
- 对原生SQL查询执行的控制是通过SQLQuery接口进行的,通过执行Session.createSQLQuery()
- 【转】在SQL Server中通过SQL语句实现分页查询
- 通过查询结果进行分页 (From derny)
- 在SQL Server中通过SQL语句实现分页查询(转)
- 通过LDAP在AD域控上进行添加、删除、修改、查询等各种操作
- C#通过SQL语句查询结果分页不用GridView的实现
- 简单sql查询接口(输入user:pwd@host即可进行sql语句操作)
- 在SQL Server中通过SQL语句实现分页查询
- 通过sql语句查询实现分页
- 在SQL Server中通过SQL语句实现分页查询
- 简单sql查询接口(需要在文件中指定conn才能进行sql语句操作)
- 通过组合条件对DAO进行查询操作
- 使用SQL语句对表进行分页查询
- JDBC实现数据库的几种基本操作(查询,分页查询,根据关键字进行查询以及插入数据)
- 导入外部数据+SQL语句的办法不支持参数查询,不过可以通过子查询进行模拟