Compound relations

Hi mates,

Now I am trying to code a new site based on Yii 1.0.7

I have next tables in my DB:




So, in catalogue we can add a book title that is related to countries because I need to specify to witch country does the book title belongs to. After this I want to do a press release of an appropriate catalogue item (for a book). So, in ‘show’ view of the PressRelease we will have:

Catalogue item with all sufficient for the press release data, country, press release fields.

So, we have PressRelease relations :

'catalogueItem' => array(self::BELONGS_TO, 'Catalogue', 'IDCatalogueItem'),

Catalogue relations:

'country' =>  array(self::BELONGS_TO, 'Countries', 'countryCode'),

Loading a press release:

$this->_model=PressRelease::model()->with(array('catalogueItem', ''=>array('select'=>'name')))->findbyPk($id!==null ? $id : $_GET['id']);

than we put this data to the press release ‘show’ view… But I can not retrieve $model->catalogueItem-><FIELD>

Any ideas?

Sorry. My bad - I’ve specified $catalogueItem in the PressRelease model, so I tried to access an internal class varibale to get a Model Catalogue :) Sorry for bothering… I’d better take a walk because of lack of focus :)

thanks, but I still don’t know how to use relations function in Model layer. Could you explain it for me ?