relation with condition

Hi,

i have those two tables that both have the attribute languagecode and also both have the attribute description_id.

Now i want to get the related entries using the relations attribute of one of their models.

so in "relations()" in model1 i added:


	

'descriptionType'	=> array(

	self::HAS_MANY, 

	'hotel_description_types', 

	'descriptiontype_id',

	'condition'=>'hotel_description_types.languagecode=:lang',

	'params' => array(':lang'=>'de'),

), ...

Now yii tells me:


CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'hotel_description_types.languagecode' in 'where clause'

… though it DOES exist in the Database! I tripple checked!

What could be the problem?

Use this condition instead, the table will get an alias that is the same as the relation name:


'condition'=>'descriptionType.languagecode=:lang',

Try


	

'descriptionType'	=> array(

	self::HAS_MANY, 

	'hotel_description_types', 

	'descriptiontype_id',

	'condition'=>'descriptionType.languagecode=:lang',

	'params' => array(':lang'=>'de'),

), ...



(not tested)

/Tommy

Didn’t work either :(


CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'descriptionType.languagecode' in 'where clause'