customer_table = "customer"; $this->category_table = "category"; $this->product_table = "product"; $this->price_table = "price"; $this->priceset_table = "priceset"; $this->tax_table = "tax"; $this->bill_table = "bill"; $this->bill_product_table = "bill_product"; $this->tour_table = "tour"; $this->assistant_table = "assistant"; $this->group_table = "`group`"; $this->customer_template_table = "customer_template"; $this->ready = false; } function connectToDb() { $host = getenv('CLOUDRON_MYSQL_HOST'); $user = getenv('CLOUDRON_MYSQL_USERNAME'); $password = getenv('CLOUDRON_MYSQL_PASSWORD'); $db = getenv('CLOUDRON_MYSQL_DATABASE'); $port = getenv('CLOUDRON_MYSQL_PORT'); // $host = "mysql5.nebulon.de"; // $user = "db30675_9"; // $password = "manda1337"; // $db = "db30675_9"; // $host = "localhost"; // $user = "root"; // $password = ""; // $db = "faursprung_net"; $this->db_link = mysqli_connect($host, $user, $password); if(!$this->db_link) exit("Error: ".mysqli_connect_error()); if(!mysqli_select_db($this->db_link, $db)) exit("Error: selecting db"); $this->ready = TRUE; } function query($query) { if(!$this->ready) $this->connectToDb(); if(!($result = mysqli_query($this->db_link, $query))) echo "Error: ".mysqli_error($this->db_link); return $result; } function fetchRows($result) { if(!$this->ready) $this->connectToDb(); $all_rows = array(); while($row = mysqli_fetch_row($result)) $all_rows[] = $row; return $all_rows; } function writeToFile($path, $data) { $file_access_ok = true; $file_open = false; clearstatcache(); if (file_exists($path)) if (!is_writable($path)) $file_access_ok = false; if ($file_access_ok and (!$file_handle = fopen($path, "w+b"))) $file_access_ok = false; if ($file_access_ok) { if (!fwrite($file_handle, $data) and ($data != '')) $file_access_ok = false; else $file_open = true; } if ($file_open) fclose($file_handle); return $file_access_ok; } } ?>