I have table with user profile and table with countries, profile table has field country_id that is not PK. But I want to retrieve user country with relational AR so I tried to map it using HAS_ONE
‘location’ => array(self::HAS_ONE, ‘Location’, ‘id’) if used in the Profile Model this try to make a relation from Profile and Location based on Profile.id that must be a FK for another key in Location. You have to add this in the DB schema of the tables or you have to use row sql
I've successfully solved my problem with the next relation in profile model (thanks to StErMi and 20th time read of manual) : 'location' => array(self::BELONGS_TO, 'Location', 'country_id'),
But strange thing happened. I had my old relation, than I changed my relation to new one, refreshed the page - nothing changed. After that I changed relation name to location1 and that did the trick. Is there some kind of caching mechanism on relations?