public function connect()
{
if (empty($this->handler)) {
try {
$this->checkConnect();
$this->log("Connect to " . $this->connect['host']);
$this->handler = new \PDO($this->connect['type'] . ":host=" . $this->connect['host'] . ";dbname=" . $this->connect['name'], $this->connect['user'], $this->connect['pass'], $this->connect['options']);
foreach ($this->attributes as $attribute => $value) {
$this->handler->setAttribute($attribute, $value);
}
$this->ok();
} catch (\Exception $e) {
throw new DbException('Attempt connection to database is failed: ' . $e->getMessage());
}
}
return $this;
}