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_jujian(){ $q = "SELECT * FROM jujian ORDER BY kdjnsujian"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_jujian(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('jujian',$dataArray); return $ret; } function update_jujian(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $this->db->where('idjnsujian', $_POST['idjnsujian']); $this->db->update('jujian', $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_jujian(){ $where['idjnsujian'] = $_POST['idjnsujian']; $ret = $this->rhlib->deleteRecord('jujian',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdjnsujian'=> $_POST['kdjnsujian'], 'nmjnsujian'=> $_POST['nmjnsujian'], 'deskripsi'=> $_POST['deskripsi'] ); return $dataArray; } } ?>