Unable to get with() to work...

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

Ok, I think I got things working now… The records I was testing against didn’t have a related row, so it was failing.

/deletepost

/crawl back into hole

Thanks to anyone who looked!

-Matt