Custom select in relation

I have an AR class like this:

class Product extends CActiveRecord



  public function relations()


    return array(

      'lang' => array(self::HAS_ONE, 'Product_lang', 'id', 'alias' => 'lang', 'select'=>'lang.name_' . Yii::app()->user->language . ' as product_name'),





Unless I add

public $product_name;

to Product_lang I get an exception



Property "Product_lang.product_name" is not defined.

Is that supposed to be like that?

Thanks in advance

Yes, this is because product_name is not an actual field on your table, so you need to define it as a public property of your model.

Thanks for help and quick reply :)