我会在一个字段中有 2 个自定义字段。我怎样才能做到这一点?
代码:
$criteria = new CDbCriteria;
$criteria->select='(number*2) AS custom_field, (number*4) AS custom_field';
$criteria->order='custom_field';
$model = Events::model()->findAll($criteria);
桌子:
number custom_field
------------------
2 4, 8
3 6, 12
custom_field ordered -> 4, 6, 8, 12
编辑:
<?php $this->widget('bootstrap.widgets.TbGridView',array(
'type'=>'striped bordered condensed',
'id'=>'recurringevents-grid',
'dataProvider'=>$model,
'columns'=>array(
'custom_field',
),
)); ?>
输出:
Custom Field
4
6
8
12