YII框架CGridView sql有条件分页实现

$SQL="SELECT * FROM {{user}} WHERE `typeff`=2 order by create_time desc";

        $SQL_count="SELECT count(*) FROM {{user}} WHERE `typeff`=2 order by create_time desc";
$count=Yii::app()->db->createCommand($SQL_count)->queryScalar(); $dataProvider=new CSqlDataProvider($SQL, array(
'totalItemCount'=>$count,
'sort'=>array(
'attributes'=>array(
'id','email','company_name','company_full_name','company_status','company_dengji_step','company_verify_tel'
),
),
'pagination'=>array(
'pageSize'=>10,
),
));
$this->render('auditing',array(
'dataProvider'=>$dataProvider,
'model'=>$model, ));

V视图

$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'table-responsive',
'itemsCssClass' => 'table table-striped table-bordered table-advance table-hover',
'pagerCssClass'=>'margin-top-20',
'htmlOptions'=>array('class'=>'table-responsive'),
'pager'=>array(
'class'=>'CLinkPager',
'header'=>'',
'htmlOptions'=>array('class'=>'pagination'),
),
'dataProvider'=>$dataProvider,
'columns'=>array(
'id',
'email',
'company_name',
'company_full_name',
array(
'name'=>'company_status',
'value'=>'$data["company_status"] == 0 ? "待审" : "通过"'
),
'company_dengji_step',
'company_verify_tel',
array(
'header'=>'操作',
'value'=>'createOperationHtmlForTable($data["id"])',
'type'=>'html',
'htmlOptions' => array('style' => 'width:200px;'),
)
) ));

效果图YII框架CGridView sql有条件分页实现

上一篇:RAC建立过程回顾--建立用户和组


下一篇:如何查看 Ubuntu下已安装包版本号