I have a problem with the relations in Yii.
I have a location, and it’s branch
each branch has many locations and each locations has only one branch
branch relations:
public function relations()
{
return array(
'locations' => array(self::HAS_MANY, 'Location', 'branch'),
);
}
location relations:
public function relations()
{
return array(
'branch0' => array(self::BELONGS_TO, 'Branch', 'branch'),
);
}
but when I try to retrieve the branch with:
Location::model()->with('branch0')->find('t.id = 1')->branch;
I only get the id of the branch, any ideas
PS: I don’t think the ‘t.id = 1’ is a clean way of doing it, I have to use a DBCriteria don’t I?