db = new mysqli($host, $uname, $passwd, $dbname); if ($this->db->connect_error) throw new Exception("Can not connect to MySQL database. Please check your configuration."); } /* * Close connection to DB */ public function close() : void { $this->db->close(); } /* * Make a query of the database. Return data as an array of arrays. */ public function query(string $query) : array { $arr = array(); $res = $this->db->query($query); if ($res === true || $res === false) return $arr; while (($arr[] = $res->fetch_assoc())); return $arr; } /* * Escape a string for use in a query */ public function esc(string $str) : string { return $this->db->real_escape_string($str); } } ?>