Hello all:
I have a model have some relations ,Now I want to get every relation’s value ,such as this:
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'worktime_user'=>array(self::BELONGS_TO,'User','customer'),
'worktime_user1'=>array(self::BELONGS_TO,'User','principal'),
);
}
public function getRelationValue($model)
{
$rs = $model->getMetaData()->relations;
foreach ( $rs as $rel)
{
//Get related model User's name ,but the result is 'worktime_user.name', not the real value;
echo $model->getAttribute($r->name.'.name');
}
}
this code has no effect, how can i do is right?
[color="#FF0000"]
//Get related model User’s name ,but the result is ‘worktime_user.name’, not the real value;
echo $model->getAttribute($r->name.'.name');[/color]
Many thanks!!