I’ve done a bunch of google search and literally “read the sh1t, out of this page” Relational AR. So I’m stumped on how to make it work right. I was able to make a regular join query work the manual way, but its not what I want – I want to do this the Yii way of course!
Here’s some code:
// Inside my test controller
$guide = Guide::model()->user(2)->with('asset')->findAll();
Here’s what I added to my Guide Model:
// Guide Model
public function relations()
{
return array(
'asset'=>array(self::BELONGS_TO, 'Asset', 'assetId'),
);
}
I’ve tried this with & w/o the ‘together’=>true parameter as well.
As far as the data records go, the Guide model with always have less records than the Asset model. Do they have to be a 1-1 match or would it just return the Asset model attributes joined to the Guide model attributes??
Inquiring mind…wants to know!
Thanks,
Matt