Condition Relational Query Error


i have relational between 2 tables. sylabus.subject_id referenced to so i have reational generated by yii

'silabuses' => array(self::HAS_MANY, 'Silabus', 'matakuliah_id'

how do i get record with condition

i have tried this

'silabuses' => array(self::HAS_MANY, 'Silabus', 'matakuliah_id',



but got an error

CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'silabus.matakuliah_id' in 'where clause'. The SQL statement executed was: SELECT `t`.`id` AS `t0_c0`, `t`.`matakuliah` AS `t0_c1`, `silabuses`.`id` AS `t1_c0`, `silabuses`.`matakuliah_id` AS `t1_c1`, `silabuses`.`silabus` AS `t1_c2` FROM `matakuliah` `t` LEFT OUTER JOIN `silabus` `silabuses` ON (`silabuses`.`matakuliah_id`=`t`.`id`) WHERE (silabus.matakuliah_id=:code)

thank you in advance.

change this


to this



Your Relation Name is silabuses so use

 	'condition'=>'silabuses.matakuliah =:code',

instead of


hello… it works… :)

thank you very much Orey and Nisanth…