我不完全了解yii框架。如何为这样的案件制作CDbCriteria? 我有一个像这样的基本查询代码。
SELECT
jam_kerja.id,
jam_kerja.id_cabang,
jam_kerja.tgl_berlaku,
jam_kerja_detail.id_jam_kerja,
jam_kerja_detail.shift,
jam_kerja_detail.jamkerja,
jam_kerja_detail.jamistirahat
FROM
jam_kerja ,
jam_kerja_detail
WHERE
jam_kerja_detail.id_jam_kerja = jam_kerja.id and jam_kerja.id_cabang=5
也许有可以帮助我的Yii朋友?
答案 0 :(得分:0)
$criteria = new CDbCriteria();
$criteria->select = 't.id,t.id_cabang, t.tgl_berlaku, jd.id_jam_kerja, jd.shift ,jd.jamkerja,';
$criteria->join = 'INNER JOIN jam_kerja_detail jd ON t.id = jd.id_jam_kerja';
$criteria->addCondition('t.id_cabang=5'); // edited this line
//and now give this criteria to your model
$model = YourModel::model()->findAll($criteria);
答案 1 :(得分:0)
我终于找到了解决方案,对其他朋友可能有用。
$criteria=new CDbCriteria;
$criteria->join='INNER JOIN jam_kerja t1 ON t1.id=t.id_jam_kerja';
$criteria->condition='t1.id_cabang='.$_GET['id'];