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_jsemester(){ $q = "SELECT * FROM jsemester ORDER BY kdjnssemester"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_jsemester(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('jsemester',$dataArray); $this->rhlib->insertRecordPublic('jsemester',$dataArray); return $ret; } function update_jsemester(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $where['idjnssemester'] = $_POST['idjnssemester']; $this->db->where('idjnssemester', $_POST['idjnssemester']); $this->db->update('jsemester', $fieldsAndValues); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; $this->rhlib->updateRecordPublic('jsemester',$fieldsAndValues,$where); }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function delete_jsemester(){ $where['idjnssemester'] = $_POST['idjnssemester']; $ret = $this->rhlib->deleteRecord('jsemester',$where); $this->rhlib->deleteRecordPublic('jsemester',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdjnssemester'=> $_POST['kdjnssemester'], 'nmjnssemester'=> $_POST['nmjnssemester'], 'deskripsi'=> $_POST['deskripsi'] ); return $dataArray; } } ?>