$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变量创建属性?
SELECT * FROM mytable WHERE date < DATE_SUB(NOW(), INTERVAL 30 DAY);
Run Code Online (Sandbox Code Playgroud)
我怎样才能在 Dotrine 1.2 中做到这一点?
<?php
$array = array('aaa', 'bbb', 'aaa', 'ccc', 'ddd', 'ccc', 'eee');
foreach($array as $a){
echo $a;
}
Run Code Online (Sandbox Code Playgroud)
有可能像DISTINCT一样使用foreach吗?我想只显示一个值,不重复.这是怎么回事?