db = new Database(); } function create($customer_id, $value) { $query = "INSERT INTO ".$this->db->customer_table." VALUES('".$customer_id."'"; for($i = 0; $i < count($value); $i++) $query .= ", '".str_replace("'", "\'", $value[$i])."'"; $query .= ")"; $this->db->query($query); } function update($customer_id, $value) { $query = "UPDATE ".$this->db->customer_table." SET "; $query .= "password='".str_replace("'", "\'", $value[0])."', "; $query .= "prename='".str_replace("'", "\'", $value[1])."', "; $query .= "postname='".$value[2]."', "; $query .= "street='".$value[3]."', "; $query .= "streetnumber='".$value[4]."', "; $query .= "plz='".$value[5]."', "; $query .= "city='".$value[6]."', "; $query .= "telephone='".$value[7]."', "; $query .= "telefax='".$value[8]."', "; $query .= "email='".$value[9]."', "; $query .= "pricelist_id='".$value[10]."', "; $query .= "tour_id='".$value[11]."', "; $query .= "rabatt='".$value[12]."', "; $query .= "details='".$value[13]."', "; $query .= "bank_name='".$value[14]."', "; $query .= "bank_account='".$value[15]."', "; $query .= "blz='".$value[16]."' "; $query .= "WHERE customer_id='".$customer_id."'"; $this->db->query($query); } function delete($customer_id) { $query = "DELETE FROM ".$this->db->customer_table." WHERE customer_id='$customer_id'"; $this->db->query($query); } function exists($customer_id) { $query = "SELECT customer_id FROM ".$this->db->customer_table." WHERE customer_id='".$customer_id."'"; $result = $this->db->fetchRows($this->db->query($query)); if(count($result) > 0) return true; else return false; } function get($customer_id = "", $row_names = array(), $search = "") { if($customer_id == "") { if(count($row_names) == 0) $query = "SELECT * FROM ".$this->db->customer_table; else { $query = "SELECT ".$row_names[0]; for($i = 1; $i < count($row_names); $i++) $query .= ", ".$row_names[$i]; $query .= " FROM ".$this->db->customer_table; } if($search != "") $query .= " WHERE ".$search; $query .= " ORDER BY customer_id ASC"; return $this->db->fetchRows($this->db->query($query)); } else { if(count($row_names) == 0) $query = "SELECT * FROM ".$this->db->customer_table; else { $query = "SELECT ".$row_names[0]; for($i = 1; $i < count($row_names); $i++) $query .= ", ".$row_names[$i]; $query .= " FROM ".$this->db->customer_table; } $query .= " WHERE customer_id='".$customer_id."'"; $query .= " ORDER BY customer_id ASC"; return $this->db->fetchRows($this->db->query($query)); } } function export($path) { $csv_data = ""; $query = "SELECT * FROM ".$this->db->customer_table; $result = $this->db->query($query); while ($row = mysqli_fetch_assoc($result)) $csv_data .= implode('|', $row)."\n"; $this->db->writeToFile($path, $csv_data); } } ?>