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_stabsenmhs(){ $q = "SELECT * FROM stabsenmhs ORDER BY kdstabsensimhs"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_stabsenmhs(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('stabsenmhs',$dataArray); return $ret; } function update_stabsenmhs(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $this->db->where('idstabsenmhs', $_POST['idstabsenmhs']); $this->db->update('stabsenmhs', $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_stabsenmhs(){ $where['idstabsenmhs'] = $_POST['idstabsenmhs']; $ret = $this->rhlib->deleteRecord('stabsenmhs',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdstabsensimhs'=> $_POST['kdstabsensimhs'], 'nmstabsensimhs'=> $_POST['nmstabsensimhs'], 'deskripsi'=> $_POST['deskripsi'] ); return $dataArray; } } ?>