<?php
$_DBCONN;
function init_connect_to_db() {
global $_DBCONN;
$config = conf();
try {
$_DBCONN = new PDO(
"mysql:host={$config["db"]["host"]};dbname={$config["db"]["dbname"]};charset=utf8mb4",
$config["db"]["user"],
$config["db"]["password"],
[
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8mb4"
]
);
} catch(PDOException $e) {
throw new Exception("Ошибка подключения: " . $e -> getMessage());
}
}
include "include/helpers.php";
init_connect_to_db();