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_thnakademik(){ $q = "SELECT idthnakademik, kdthnakademik, nmthnakademik, deskripsi FROM thnakademik ORDER BY kdthnakademik DESC"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_thnakademik(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('thnakademik',$dataArray); $this->rhlib->insertRecordPublic('thnakademik',$dataArray); return $ret; } function update_thnakademik(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $where['kdthnakademik'] = $_POST['kdthnakademik']; $this->db->where('kdthnakademik', $_POST['kdthnakademik']); $this->db->update('thnakademik', $fieldsAndValues); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; $this->rhlib->updateRecordPublic('thnakademik',$fieldsAndValues,$where); }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function delete_thnakademik(){ $where['kdthnakademik'] = $_POST['kdthnakademik']; $ret = $this->rhlib->deleteRecord('thnakademik',$where); $this->rhlib->deleteRecordPublic('thnakademik',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdthnakademik'=> $_POST['kdthnakademik'], 'nmthnakademik'=> $_POST['nmthnakademik'], 'deskripsi'=> $_POST['deskripsi'] ); return $dataArray; } } ?>