load->library('session'); $this->load->library('rhlib'); } function retValOrNull($val){ //especially for combo & looukup with no item selected $val = ($val=='')? null : $val; return $val; } function get_carabyr(){ $q = "SELECT * FROM carabyr ORDER BY kdcarabyr"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_carabyr(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('carabyr',$dataArray); $this->rhlib->insertRecordPublic('carabyr',$dataArray); return $ret; } function update_carabyr(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $where['idcarabyr'] = $_POST['idcarabyr']; $this->db->where('idcarabyr', $_POST['idcarabyr']); $this->db->update('carabyr', $fieldsAndValues); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; $this->rhlib->updateRecordPublic('carabyr',$fieldsAndValues,$where); }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function delete_carabyr(){ $where['idcarabyr'] = $_POST['idcarabyr']; $ret = $this->rhlib->deleteRecord('carabyr',$where); $this->rhlib->deleteRecordPublic('carabyr',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdcarabyr'=> $_POST['kdcarabyr'], 'nmcarabyr'=> $_POST['nmcarabyr'], 'deskripsi'=> $_POST['deskripsi'] ); return $dataArray; } } ?>