<?php
class Database {
    private $server_name = HOST_DB;
    private $db_name     = NAME_DB;
    private $user_name   = USER_DB;
    private $password    = PASS_DB;

    private $con;

    public function __construct() {
        $this->con = new mysqli($this->server_name, $this->user_name, $this->password, $this->db_name);
        if ($this->con->connect_error) {
            die("DB Connection failed: " . $this->con->connect_error);
        }
        $this->con->set_charset('utf8mb4');
    }

    public function query($sql) {
        return $this->con->query($sql);
    }

    public function escape($str) {
        return $this->con->real_escape_string($str);
    }

    public function insert_id() {
        return $this->con->insert_id;
    }

    public function getConnection() {
        return $this->con;
    }
}
?>
