I’ll try to be as explicit as possible:<br class=""> then, I have the table RATING and the table MUSIC , table RATING has a field related to the MUSIC table:
Model Rating:
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(
'music' => array(self::BELONGS_TO, 'Music', 'musicid'),
);
}
Model Music:
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(
'gen' => array(self::BELONGS_TO, 'Genres', 'genid'),
'user' => array(self::BELONGS_TO, 'YumUser', 'userid'),
'ratings' => array(self::HAS_MANY, 'Rating', 'musicid'),
);
}
and I am getting the data in the controller as follows:
$dataProvider=new CActiveDataProvider('Music', array(
'pagination'=>array(
'pageSize'=>Yii::app()->params['musicpp'],
),
));
and then after that will be read in CListView, and so far so good, in the other relationships, in _view I can get such $data->gen->name, but when I try to do the same with the rating, such $data->ratings->rate, give me this error [color="#8B0000"][b]Trying to get property of non-object
[/b][/color][color="#8B0000"][color="#000000"]Which basically i want is a way to get the ratings of the current record from the table music (yes because a music can have various ratings)
[/color][/color][color="#8B0000"][color="#000000"]Someone can help me with this? This is my project to start learning Yii, but I’m a little lost, I already read the documentation but I understand better with practical examples[/color][/color]