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_setipk(){ $q = "SELECT * FROM setipk ORDER BY ipkdari"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_setipk(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('setipk',$dataArray); return $ret; } function update_setipk(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $this->db->where('idsetipk', $_POST['idsetipk']); $this->db->update('setipk', $fieldsAndValues); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function delete_setipk(){ $where['idsetipk'] = $_POST['idsetipk']; $ret = $this->rhlib->deleteRecord('setipk',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'ipkdari'=> $_POST['ipkdari'], 'ipksampai'=> $_POST['ipksampai'], 'keterangan'=> $_POST['keterangan'] ); return $dataArray; } } ?>