0
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') 的返回记录?这样我们就可以检查它是否工作?

4

1 回答 1

0

你可以简单地写:

$data->phoneNumberGroupAssignments

或一般来说:

$data->relation-name

这是可能的,因为 YiiCActiveRecord重新定义了魔法 getter 方法__get()链接


更新

所以你可以写这样的代码:

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',
),
于 2012-11-15T10:26:40.257 回答