db = new Database(); } function create($value) { $query = "INSERT INTO ".$this->db->tour_table." VALUES(''"; for($i = 0; $i < count($value); $i++) $query .= ", '".$value[$i]."'"; $query .= ")"; $this->db->query($query); } function update($tour_id, $value) { $query = "UPDATE ".$this->db->tour_table." SET "; $query .= "name='".$value[0]."', "; $query .= "assistant_id='".$value[1]."' "; $query .= "WHERE tour_id='".$tour_id."'"; $this->db->query($query); } function delete($tour_id) { $query = "DELETE FROM ".$this->db->tour_table." WHERE tour_id='$tour_id'"; $this->db->query($query); } function get($tour_id = "", $row_names = array(), $search = "") { if($tour_id == "") { if(count($row_names) == 0) $query = "SELECT * FROM ".$this->db->tour_table; else { $query = "SELECT ".$row_names[0]; for($i = 1; $i < count($row_names); $i++) $query .= ", ".$row_names[$i]; $query .= " FROM ".$this->db->tour_table; } if($search != "") $query .= " WHERE ".$search; $query .= " ORDER BY tour_id ASC"; return $this->db->fetchRows($this->db->query($query)); } else { $query = "SELECT * FROM ".$this->db->tour_table." WHERE tour_id='".$tour_id."'"; $query .= " ORDER BY tour_id ASC"; return $this->db->fetchRows($this->db->query($query)); } } function getByAssistant($assistant_id) { if($assistant_id == "") { $query = "SELECT * FROM ".$this->db->tour_table; $query .= " WHERE assistant_id='".$assistant_id."' "; $query .= " ORDER BY tour_id ASC"; return $this->db->fetchRows($this->db->query($query)); } } } ?>