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->bill_import_table = "bill_import"; $this->bill_product_import_table = "bill_product_import"; $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'); $this->db_link = mysqli_connect($host, $user, $password, $db, $port); if(!$this->db_link) { echo "Error: ".mysqli_connect_error(); exit(1); } mysqli_set_charset($this->db_link, "latin1"); $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; } } ?>