gastrodata/Database.class.php

34 lines
881 B
PHP
Raw Normal View History

<?php
2020-08-09 12:51:57 +00:00
class Database {
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);
}
}