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

Weird Relation Query.

$
0
0
Hi,

I have this tables:
product (
  id,
  ...
);

product_translation (
  product_id,
  lang_code,
  name,
  ...
);


When I get the Product with its relation from product_translation I want it according to the user selected language, so on the relation I have:

  'productTranslation' => array(self::HAS_ONE, 'ProductTranslation', 'product_id',
    'condition'=>Yii::app()->db->quoteColumnName('productTranslation.lang_code')."='".Yii::app()->user->language."'"
  ),


The problem is that the translation in the user language might not exist, so get it in the default language.

How can I do this?

Viewing all articles
Browse latest Browse all 18717

Trending Articles



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