array(
'header'=>assignment::model()->getAttributeLabel('group_id'), //column header
'value'=>'($data->getRelated(\'phoneNumberGroupAssignments\')=== null)?"No related assignment registry":$data->getRelated("phoneNumberGroupAssignments")->group_id', //column name, php expression
'type'=>'raw',
),
如何打印/回显getrelated('relation-name')的返回记录? 这样我们就可以检查它是否有效?
答案 0 :(得分:0)
您可以简单地写一下:
$data->phoneNumberGroupAssignments
或一般情况下:
$data->relation-name
有可能,因为Yii CActiveRecord
重新定义了魔法吸气剂方法__get()
(link)
<强>更新强>
所以你可以编写这样的代码:
array(
'header' => assignment::model()->getAttributeLabel('group_id'), //column header
'value' => '($data->phoneNumberGroupAssignments === null) ? "No related assignment registry" : $data->phoneNumberGroupAssignments->group_id', //column name, php expression
'type'=>'raw',
),