Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Activerecord Relations Question

$
0
0
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:
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)?

Viewing all articles
Browse latest Browse all 18717

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>