From 41523e6899f10d3f9e31eeb962fc829cbd577f38 Mon Sep 17 00:00:00 2001 From: User Date: Sat, 19 Apr 2025 18:45:41 +0300 Subject: [PATCH] 20250419#1 --- src/Mysql/MysqlStorage.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/Mysql/MysqlStorage.php b/src/Mysql/MysqlStorage.php index 7e5021c..5391bbc 100644 --- a/src/Mysql/MysqlStorage.php +++ b/src/Mysql/MysqlStorage.php @@ -13,26 +13,23 @@ class MysqlStorage implements MysqlStorageInterface { private Mysqli $mysqli; /** - * Внутренний конструктор подключения к БД - * Mysql constructor. - * @param object $params + * @param array $paramsArray * @throws Exception */ - public function __construct( - private readonly object $params - ) { + public function __construct(array $paramsArray) { + $params = (object) $paramsArray; $this->mysqli = new mysqli( - $this->params->host, - $this->params->user, - $this->params->pass, - $this->params->base + $params->host, + $params->user, + $params->pass, + $params->base ); // выводим ошибку при неудачном подключении if ($this->mysqli->connect_errno) { throw new Exception($this->mysqli->connect_errno); } - $this->mysqli->set_charset("utf8"); - if(!empty($this->params->logsEnable)) $this->logsEnabled = true; + $this->mysqli->set_charset($params->chartset ?? "utf8"); + if(!empty($params->logs)) $this->logsEnabled = true; } /** @inheritDoc */