2020-08-05 05:51:29 +00:00
|
|
|
<?php
|
|
|
|
|
2020-08-09 12:51:57 +00:00
|
|
|
class Database {
|
2020-08-05 05:51:29 +00:00
|
|
|
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);
|
|
|
|
}
|
2020-08-09 12:51:57 +00:00
|
|
|
|
|
|
|
public static function execute_query($query="")
|
|
|
|
{
|
|
|
|
return (new self())->query($query);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function escape_string($string="")
|
|
|
|
{
|
|
|
|
return (new self())->escape($string);
|
|
|
|
}
|
2020-08-05 05:51:29 +00:00
|
|
|
}
|