I have the tables activity and translation with the following properties:
I am struggling to define a proper relation for the Activity model with the Translation model. Every activity record has one translation for a given language. According to this topic it should be possible to specify a relation on a column other than the primary key. I specified the following relation for the Activity model:
'translation' => array( self::HAS_ONE, 'Translation', '', 'on' => 'actPhraseId = trPhraseId', 'condition' => 'trLanguageId = 1', )
(as suggested in the other topic by qiang). Unfortunately this fails:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'actPhraseId' in 'where clause'. The SQL statement executed was: SELECT `translation`.`trId` AS `t1_c0`, `translation`.`trPhraseId` AS `t1_c1`, `translation`.`trLanguageId` AS `t1_c2`, `translation`.`trText` AS `t1_c3` FROM `translation` `translation` WHERE (trLanguageId = 1) AND (actPhraseId = trPhraseId)
I don’t understand why the on part is converted to a where clause, this seems wrong. Any ideas on how to make this work are greatly appreciated.