diff --git a/src/Database.php b/src/Database.php index d032133..f8d9320 100644 --- a/src/Database.php +++ b/src/Database.php @@ -45,6 +45,8 @@ class Database extends QueryBuilder 'password' => null, 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', + 'persistent' => null, + 'options' => [], 'tableSchema' => null, 'tableSchemaID' => null, 'entity' => Entity::class, @@ -138,6 +140,9 @@ final public function getPDO(): PDO PDO::ATTR_PERSISTENT => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, ]; + if (\is_bool($this->_credentials['persistent'])) { + $options[PDO::ATTR_PERSISTENT] = $this->_credentials['persistent']; + } switch ($this->_credentials['return']) { case null: case self::ARRAY: @@ -159,6 +164,10 @@ final public function getPDO(): PDO $options[PDO::ATTR_DEFAULT_FETCH_MODE] = PDO::FETCH_BOTH; } + if (\is_array($this->_credentials['options']) && !empty($this->_credentials['options'])) { + $options = \array_merge($options, $this->_credentials['options']); + } + $this->_pdo = new PDO($this->_credentials['dsn'], $this->_credentials['username'], $this->_credentials['password'], $options); if(!empty($this->_credentials['charset'])){ if(!empty($this->_credentials['collation'])) {