I do not fully know yii framework. How to make CDbCriteria for cases like this? I have a basic query code like this.
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
Maybe there Yii friends who can help me?
$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);