如何在YII

时间:2015-11-10 11:05:49

标签: php yii

我想从PHP升级到YII,但我遇到了这个问题。这是代码

`

select  h.Kelas_ID KelasAlias, h.Ruangan_ID RuanganAlias, j.Jadwal_ID, j.Ruangan_ID, j.Kelas_ID, c.Kelas, r.Ruangan 
From kehadiran h LEFT join jadwal j on h.Guru_ID = j.Guru_ID and h.Kelas_ID = j.Kelas_ID and h.Ruangan_ID = j.Ruangan_ID
left join kelas c on c.Kelas_ID=h.Kelas_ID 
LEFT join ruangan r on r.Ruangan_ID=h.Ruangan_ID
where h.Guru_ID = '1'
group by c.Kelas_ID, r.Ruangan_ID 
union all
SELECT  j.Kelas_ID KelasAlias, j.Ruangan_ID RuanganAlias, j.Jadwal_ID, j.Ruangan_ID, j.Kelas_ID, c.Kelas, r.Ruangan 
FROM jadwal j LEFT JOIN kelas c ON c.Kelas_ID=j.Kelas_ID 
LEFT JOIN ruangan r ON r.Ruangan_ID=j.Ruangan_ID  
WHERE j.Guru_ID = '1'
GROUP BY c.Kelas_ID, r.Ruangan_ID

`

但是现在如何在YII中使用union

1 个答案:

答案 0 :(得分:1)

您可以使用findAllBySql并使用您喜欢的SQL查询获取结果

DialogFragmentImage