I have 3 tables: texts, texts_regional, languages.
texts_regional of course has parts of texts that go in different languages with columns: text_id, lang_id, title, description.
I would like to make a relation in the model Text so I can access regional data for current language easily.
What I have now is:
But that returns all the languages in an array and that's way too much resources sometimes. Is there a way to make a relation to just get the language i request, like: $text->regional(Yii::app()->lang)?
texts_regional of course has parts of texts that go in different languages with columns: text_id, lang_id, title, description.
I would like to make a relation in the model Text so I can access regional data for current language easily.
What I have now is:
class Text extends CActiveRecord { public function relations() { return array( 'regional' => array(self::HAS_MANY, 'TextRegional', 'text_id', 'index'=>'lang_id'), ); } }
But that returns all the languages in an array and that's way too much resources sometimes. Is there a way to make a relation to just get the language i request, like: $text->regional(Yii::app()->lang)?