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_stambilmk(){ $q = "SELECT * FROM stambilmk ORDER BY kdstambilmk"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_stambilmk(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('stambilmk',$dataArray); return $ret; } function update_stambilmk(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $this->db->where('idstambilmk', $_POST['idstambilmk']); $this->db->update('stambilmk', $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_stambilmk(){ $where['idstambilmk'] = $_POST['idstambilmk']; $ret = $this->rhlib->deleteRecord('stambilmk',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdstambilmk'=> $_POST['kdstambilmk'], 'nmstambilmk'=> $_POST['nmstambilmk'] ); return $dataArray; } } ?>