1

我是 Yii 的新手。关系活动记录返回此数组:

Array
(
[0] => Authitem Object
    (
        [_md:CActiveRecord:private] => 
        [_new:CActiveRecord:private] => 
        [_attributes:CActiveRecord:private] => Array
            (
                [name] => admin
                [type] => 2
                [description] => 
                [bizrule] => 
                [data] => 
            )

        [_related:CActiveRecord:private] => Array
            (
            )

        [_c:CActiveRecord:private] => 
        [_pk:CActiveRecord:private] => admin
        [_alias:CActiveRecord:private] => t
        [_errors:CModel:private] => Array
            (
            )

        [_validators:CModel:private] => 
        [_scenario:CModel:private] => update
        [_e:CComponent:private] => 
        [_m:CComponent:private] => 
    )

)

如何从 [_attributes:CActiveRecord:private] 获取数组?我已经尝试过 authMenus[0]->[_attributes:CActiveRecord:private] 和 authMenus[0]->_attributes 但没有用。

4

1 回答 1

0

您可以像这样直接访问:

$authMenus[0]->attributes;
// or in general
$array_of_active_record_objects[index]->attributes;
$array_of_active_record_objects[index]->single_attribute;

因为 CActiveRecord 有一个自定义 getter

于 2013-01-31T05:48:30.713 回答