Accessing owner of relational model

I want to do something like this


instead of


To return (generate) the correct profile url, I need the id or even more attributes of the actual user model within the profile model. Is this possible already in some way?

This is how I would like to do it:

public function getUrl()


   return Yii::app()->createUrl('user/profile', array('id' => $this->owner->id));


I guess you can do it like you wrote. That should work.

This would work if you defined the relation "owner".

CActiveRecord does not have a owner property and it would not make sense, because models could have several owners (BELONGS_TO relationships), which i assume you are refering to?