hi all developer i have query like this ini zend framework 1
function atDaftarJoinPeran($peran_id,$modul_id=null,$parent=null,$enable=null,$app_id=null) {
$s = $this->select();
$s
->setIntegrityCheck(false)
->from($this)
->join('cr_hak_akses','
(cr_hak_akses.MODUL_ID=cr_menu.MODUL_ID or cr_hak_akses.MODUL_ID=\'all\') and
(cr_hak_akses.KONTROLER_ID=cr_menu.KONTROLER_ID or cr_hak_akses.KONTROLER_ID=\'all\') and
(cr_hak_akses.AKSI_ID=cr_menu.AKSI_ID or cr_hak_akses.AKSI_ID=\'all\')
',null)
->order('MENU_ORDER')
->where('cr_hak_akses.PERAN_ID=?',$peran_id)
->where('cr_hak_akses.FLAG_AKSES=?','1')
;
if ($parent) {
$s->where('PARENT_MENU_ID = ?',$parent);
} else {
$s->where('PARENT_MENU_ID IS NULL');
}
if ($modul_id) {
$s->where('cr_menu.MODUL_ID=?',$modul_id);
}
if ($enable) {
$s->where('MENU_ENABLE=?',$enable);
}
if ($app_id) {
$s
->joinLeft('cr_modul','cr_modul.MODUL_ID=cr_menu.MODUL_ID',null)
->where('cr_modul.app_id=?',$app_id)
;
}
$rs = $this->fetchAll($s);
return $rs;
}
how can i convert that query into phalcon and place it in model not in controller.
in zend i can make query with multi condition simply by inject $s->where clause or $s->join before query execution (fetch).
thanks before