Hi this, first time i use Yii,
i have a 3 tables,
one for countries,cities, the other for phrases.
Countries Table fields :
countryID
Citries Table fields :
cityID
country_ID
the phrases table
phraseKey
phraseValue
phraseLang
& i get the names from the phrases
the phraseKey is like that ‘country:’+countryID or 'city:'cityID
before i was get it like that
select *,phrases.phraseValue as countryTitle from countries,phrases where phraseKey=CONCAT('country:', countries.countryID) AND phraseLang='{CURRENT_LANUAGE_OF_THE_WEBSITE}'
so how can i do the same in Yii
in the Activerecord relations ? & how ?
is there any way more easy in Yii ? how?
what if i want to get a country title & city title in the same query in Yii ?
i can do it like that
for example i have a table for users,
userID
username
country
city
the sql :
select users.*,(select phrases.phraseValue as countryTitle from user,countries,phrases where phraseKey=CONCAT('country:', countries.countryID) AND phraseLang='{CURRENT_LANUAGE_OF_THE_WEBSITE}' AND users.country=countries.countryID) as country,(select phrases.phraseValue as cityTitle from user,cities,phrases where phraseKey=CONCAT('city:', cities.cityID) AND phraseLang='{CURRENT_LANUAGE_OF_THE_WEBSITE}' AND users.city=cities.cityID) as city from users
Thanks