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_stakreditasislta(){ $q = "SELECT * FROM stakreditasislta ORDER BY kdstakreditasislta"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_stakreditasislta(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('stakreditasislta',$dataArray); $this->rhlib->insertRecordPublic('stakreditasislta',$dataArray); return $ret; } function update_stakreditasislta(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $where['idstakreditasislta'] = $_POST['idstakreditasislta']; $this->db->where('idstakreditasislta', $_POST['idstakreditasislta']); $this->db->update('stakreditasislta', $fieldsAndValues); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; $this->rhlib->updateRecordPublic('stakreditasislta',$fieldsAndValues,$where); }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function delete_stakreditasislta(){ $where['idstakreditasislta'] = $_POST['idstakreditasislta']; $ret = $this->rhlib->deleteRecord('stakreditasislta',$where); $this->rhlib->deleteRecordPublic('stakreditasislta',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdstakreditasislta'=> $_POST['kdstakreditasislta'], 'nmstakreditasislta'=> $_POST['nmstakreditasislta'], 'deskripsi'=> $_POST['deskripsi'] ); return $dataArray; } } ?>