嗨,主人,我有 4 张桌子
-pegawai -penilaian -universitas -jurusan
我通常使用
SELECT u.nama_univ, j.singkatan, peg.* FROM pegawai AS peg LEFT JOIN penilaian AS pen ON pen.no_test=peg.no_test LEFT JOIN universitas AS u ON u.id=peg.univ_s1 LEFT JOIN jurusan AS j ON j.id=peg.bidang_s1
如何将此查询转换为 yii ?
我已经尝试过这段代码,但效果不佳
$dataProvider = new CActiveDataProvider('Pegawai', array(
'criteria' => array(
'select' => array(
'`pen`.*',
'`u`.`nama_univ` AS `nama_univ`',
'`j`.`singkatan` AS `singkatan`'
),
'join' => 'JOIN `Penilaian` AS `pen` ON `pen`.`no_test` = `t`.`no_test`',
'join' => 'JOIN `Universitas` AS `u` ON `u`.`id` = `t`.`no_test`',
'join' => 'JOIN `Jurusan` AS `j` ON `j`.`id` = `t`.`no_test`',
)
));
但只有一个 join 有执行