i try to setup a relation between two tables. but the result is not correct
he is joining the cities.id with the countries.id inseatd of cities_id_country with countries.id
when i switch de forgeinskey in de relations i get an error.
COUNTRIES
id <PK>
code
country
CITIES
id <PK>
id_country <FK1>
city
COUNRTY MODEL
'city' => array(self::HAS_MANY, 'City', 'id_country'),
CITY MODEL
'country' => array(self::HAS_ONE, 'Country', 'id'),
CONTROLLER
//query $rows = City::model()->with('country')->findAll($criteria);
VIEW
<?php foreach($cities as $city): ?> <?php echo $city->city; ?> <?php echo $city->country->country; ?> <?php endif; ?>
RESULT
# City Country 3 Amsterdam Duitsland 14 Berlijn 13 Brussel 16 Groenlo 9 Groningen 17 Haarlo 1 Londen Nederland 2 Neede België