Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c516546b5d | ||
|
|
945c95441f |
@@ -28,4 +28,12 @@ abstract class AbstractEntity implements EntityInterface {
|
|||||||
return $this->$name ?? "";
|
return $this->$name ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function __isset(string $name): bool {
|
||||||
|
return isset($this->$name);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,17 +15,24 @@ class MysqlStorage implements MysqlStorageInterface {
|
|||||||
/**
|
/**
|
||||||
* Внутренний конструктор подключения к БД
|
* Внутренний конструктор подключения к БД
|
||||||
* Mysql constructor.
|
* Mysql constructor.
|
||||||
* @param array $params
|
* @param object $params
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function __construct(array $params) {
|
public function __construct(
|
||||||
$this->mysqli = new mysqli($params['host'], $params['user'], $params['pass'], $params['base']);
|
private readonly object $params
|
||||||
|
) {
|
||||||
|
$this->mysqli = new mysqli(
|
||||||
|
$this->params->host,
|
||||||
|
$this->params->user,
|
||||||
|
$this->params->pass,
|
||||||
|
$this->params->base
|
||||||
|
);
|
||||||
// выводим ошибку при неудачном подключении
|
// выводим ошибку при неудачном подключении
|
||||||
if ($this->mysqli->connect_errno) {
|
if ($this->mysqli->connect_errno) {
|
||||||
throw new Exception($this->mysqli->connect_errno);
|
throw new Exception($this->mysqli->connect_errno);
|
||||||
}
|
}
|
||||||
$this->mysqli->set_charset("utf8");
|
$this->mysqli->set_charset("utf8");
|
||||||
if(!empty($params['logsEnable'])) $this->logsEnabled = true;
|
if(!empty($this->params->logsEnable)) $this->logsEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
|
|||||||
Reference in New Issue
Block a user