as_lh
(As)
February 12, 2010, 2:20pm
1
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?
mikl
(Mike)
February 12, 2010, 2:55pm
2
Use this condition instead, the table will get an alias that is the same as the relation name:
'condition'=>'descriptionType.languagecode=:lang',
tri
(tri - Tommy Riboe)
February 12, 2010, 2:57pm
3
as_lh:
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?
Try
'descriptionType' => array(
self::HAS_MANY,
'hotel_description_types',
'descriptiontype_id',
'condition'=>'descriptionType.languagecode=:lang',
'params' => array(':lang'=>'de'),
), ...
(not tested)
/Tommy
as_lh
(As)
February 12, 2010, 3:15pm
4
tri:
Try
'descriptionType' => array(
self::HAS_MANY,
'hotel_description_types',
'descriptiontype_id',
'condition'=>'descriptionType.languagecode=:lang',
'params' => array(':lang'=>'de'),
), ...
Didn’t work either
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'descriptionType.languagecode' in 'where clause'