db = new Database(); } function create($priceset_id, $value) { $query = "INSERT INTO ".$this->db->priceset_table." VALUES('".$priceset_id."'"; for($i = 0; $i < count($value); $i++) $query .= ", '".$value[$i]."'"; $query .= ")"; $this->db->query($query); } function update($priceset_id, $value) { $query = "UPDATE ".$this->db->priceset_table." SET "; $query .= "name='".$value[0]."', "; $query .= "netto='".$value[1]."' "; $query .= "WHERE priceset_id='".$priceset_id."'"; $this->db->query($query); } function delete($priceset_id) { $query = "DELETE FROM ".$this->db->priceset_table." WHERE priceset_id='$priceset_id'"; $this->db->query($query); } function exists($priceset_id) { $query = "SELECT priceset_id FROM ".$this->db->priceset_table." WHERE priceset_id='".$priceset_id."'"; $result = $this->db->fetchRows($this->db->query($query)); if(count($result) > 0) return true; else return false; } function get($priceset_id = "", $row_names = array(), $search = "") { if($priceset_id == "") { if(count($row_names) == 0) $query = "SELECT * FROM ".$this->db->priceset_table; else { $query = "SELECT ".$row_names[0]; for($i = 1; $i < count($row_names); $i++) $query .= ", ".$row_names[$i]; $query .= " FROM ".$this->db->priceset_table; } if($search != "") $query .= " WHERE ".$search; $query .= " ORDER BY priceset_id ASC"; return $this->db->fetchRows($this->db->query($query)); } else { if(count($row_names) == 0) $query = "SELECT * FROM ".$this->db->priceset_table; else { $query = "SELECT ".$row_names[0]; for($i = 1; $i < count($row_names); $i++) $query .= ", ".$row_names[$i]; $query .= " FROM ".$this->db->priceset_table; } $query .= " WHERE priceset_id='".$priceset_id."'"; $query .= " ORDER BY priceset_id ASC"; return $this->db->fetchRows($this->db->query($query)); } } function export($path) { $csv_data = ""; $query = "SELECT * FROM ".$this->db->priceset_table; $result = $this->db->query($query); while ($row = mysqli_fetch_assoc($result)) $csv_data .= implode('|', $row)."\n"; $this->db->writeToFile($path, $csv_data); } } ?>