小编Dir*_*ust的帖子

Yii - CGridView - 添加自己的属性

$this->widget('zii.widgets.grid.CGridView', array(
    'dataProvider'=>$dataProvider,
    'columns'=>array(
        'title',          // display the 'title' attribute
        'category.name',  // display the 'name' attribute of the 'category' relation
        'content:html',   // display the 'content' attribute as purified HTML
        array(            // display 'create_time' using an expression
            'name'=>'create_time',
            'value'=>'date("M j, Y", $data->create_time)',
        ),
        array(            // display 'author.username' using an expression
            'name'=>'authorName',
            'value'=>'$data->author->username',
//HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
              'htmlOptions'=>array('class'=>'$data->author->username', 'secondAttribute' => $data->author->id),
//HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        ),
        array(            // display a column with "view", "update" and "delete" buttons
            'class'=>'CButtonColumn',
        ),
    ),
));
Run Code Online (Sandbox Code Playgroud)

在选项中value我可以从PHP添加变量,但是对于选项,htmlOptions这是不可能的.为什么?
如何使用PHP变量创建属性?

php yii

5
推荐指数
2
解决办法
8500
查看次数

Doctrine 中的 DATE_SUB 和 INTERVAL

SELECT * FROM mytable WHERE date < DATE_SUB(NOW(), INTERVAL 30 DAY);
Run Code Online (Sandbox Code Playgroud)

我怎样才能在 Dotrine 1.2 中做到这一点?

php mysql sql doctrine

1
推荐指数
1
解决办法
5948
查看次数

关于foreach的DISTINCT

<?php

$array = array('aaa', 'bbb', 'aaa', 'ccc', 'ddd', 'ccc', 'eee');

foreach($array as $a){
   echo $a;
}
Run Code Online (Sandbox Code Playgroud)

有可能像DISTINCT一样使用foreach吗?我想只显示一个值,不重复.这是怎么回事?

http://codepad.org/FZQNEBeK

php

0
推荐指数
1
解决办法
556
查看次数

标签 统计

php ×3

doctrine ×1

mysql ×1

sql ×1

yii ×1