Cross Table Class

Hii all ;) This is my first topic so please, be patient with me.

I got 2 tables - City & Area. Area Contains City.

Area has:

  • id

  • name

City has:

  • id

  • name

  • Area_ID - Foreign key to Area-id in the Area table.

Does Yii Creates an instance of Area, every time a city is instanced? or just saving the "Area_ID" property?

I know I can call $data->Area->name from the _view.php file of the City, But I cant access the same property from the _Search.php of the City.

So for the _Search page, ive made a property of Area in the City Model. But I use it only on the _Search/_Manage pages. Ive also made the search function to work with the new property.

So some of the time I use the default of Yii (which probably creates an instance of Area…) but in the rest of the time, I Use my own Area property in the City Model (for search & admin purposes).

Is that the correct way to do it?

Now I have added a neighborhood class, and when i call $model->City it wont work :(

Anyone knows how these stuff work in yii?? :(