I’m new here and new with the Yii Framework.
Now I like to work with Relational Active Record.
I’d like to count the number of trees in an area. A tree is in a city and a city is in a region. Now I would like to return the number of trees in the region with ID 1.
In region-model stands in the relations:
return array (‘city’ => array (self :: HAS_MANY, ‘city’, ‘RegionlD’));
In the city-model stands in the relations:
return array (‘tree’ => array (self :: HAS_MANY, ‘tree’, ‘StadtID’));
So how can I count the trees?
I like to select all trees in a Region with ID=1.
Tree::model()->with(‘city’)->with(‘region’)->findAll(‘Region.ID=:id’, array(‘id’ => 1));
but the Tree Model does not know region.
Can anybody help me?