AR relations

I’ ve got the following model


class Contents extends CActiveRecord

{

	...

	public function relations()

	{

		return array(

			'text' => array(self::HAS_MANY, 'ContentsText', 'content_id'),

		);

	}

	...

}

and I trying to fetch some data using




$items = Contents::model()->with('text')->findAll('parent_id=1 AND language_id=1');

when I am trying to access


foreach ($items as $item) {

	print($item->text->title);

}

I get an error "Trying to get property of non-object".

But if I do it like this


foreach ($items as $item) {

	print($item->text[0]->title);

} 

it works!

Any ideas?

Thanks in advance

Is the type of relationship you have… self::HAS_MANY, says that it has many text… change it to self::HAS_ONE and see if it happens the same

It works…

Thanks a lot!