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_semester(){ $q = "SELECT semester.*, jsemester.nmjnssemester FROM semester LEFT JOIN jsemester ON semester.idjnssemester = jsemester.idjnssemester ORDER BY idsemester"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_semester(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('semester',$dataArray); return $ret; } function update_semester(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $this->db->where('idsemester', $_POST['idsemester']); $this->db->update('semester', $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_semester(){ $where['idsemester'] = $_POST['idsemester']; $ret = $this->rhlib->deleteRecord('semester',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'idsemester'=> $_POST['idsemester'], 'kdsemester'=> $_POST['kdsemester'], 'nmsemester'=> $_POST['nmsemester'], 'deskripsi'=> $_POST['deskripsi'], 'idjnssemester'=> $_POST['idjnssemester'], 'tingkat'=> $_POST['tingkat'] ); return $dataArray; } } ?>