gastrodata/Connection.class.php

24 lines
No EOL
662 B
PHP

<?php
class Connection {
private $mysqli = null;
public function __construct()
{
$config = require("config.php");
$this->mysqli = new mysqli($config["db_host"], $config["db_user"], $config["db_pass"], $config["db_name"], $config["db_port"]);
if ($this->mysqli->connect_errno) {
die("Failed to connect to database: (" . $this->mysqli->connect_errno . ") " . $this->mysqli->connect_error);
};
}
public function query($query="")
{
return $this->mysqli->query($query);
}
public function escape($string="")
{
return $this->mysqli->real_escape_string($string);
}
}