diff --git a/src/Config/Database/MysqliDatabase.php b/src/Config/Database/MysqliDatabase.php index 56d0371..f543c87 100644 --- a/src/Config/Database/MysqliDatabase.php +++ b/src/Config/Database/MysqliDatabase.php @@ -26,7 +26,7 @@ class MysqliDatabase extends Database * @param int $wait_timeout */ public function __construct(public string $host, public int $port, public string $dbName, public string $user, - public string $password, public string $tablePrefix = 'p_', public string $charset = 'utf8mb4', public int $wait_timeout = 3600) + public string $password, public string $tablePrefix = 'p_', public string $charset = 'utf8mb4',public bool $persistent = false, public int $wait_timeout = 3600) { } diff --git a/src/Config/Database/PdoMysqlDatabase.php b/src/Config/Database/PdoMysqlDatabase.php index 177e610..50296e9 100644 --- a/src/Config/Database/PdoMysqlDatabase.php +++ b/src/Config/Database/PdoMysqlDatabase.php @@ -26,7 +26,7 @@ class PdoMysqlDatabase extends Database * @param int $wait_timeout */ public function __construct(public string $host, public int $port, public string $dbName, public string $user, - public string $password,public string $tablePrefix = 'p_',public string $charset='utf8mb4',public int $wait_timeout = 3600) + public string $password, public string $tablePrefix = 'p_', public string $charset = 'utf8mb4', public bool $persistent = false, public int $wait_timeout = 3600) { } diff --git a/src/ORM/Connector/MysqliConnector.php b/src/ORM/Connector/MysqliConnector.php index d044d1d..c4c93f9 100644 --- a/src/ORM/Connector/MysqliConnector.php +++ b/src/ORM/Connector/MysqliConnector.php @@ -17,6 +17,11 @@ class MysqliConnector extends \QApi\ORM\Connector\Connection implements ConnectorInterface { + /** + * @param MysqliDatabase $config + * @return Connection + * @throws \Doctrine\DBAL\Exception + */ public function getConnector(mixed $config): Connection { $this->config = $config; @@ -28,6 +33,7 @@ public function getConnector(mixed $config): Connection 'port' => $config->port, 'driverClass' => Driver::class, 'charset' => $config->charset, + 'persistent' => true, ], $this->getConfiguration(), $this->getEventManager()); } } \ No newline at end of file diff --git a/src/ORM/Connector/PdoMysqlConnector.php b/src/ORM/Connector/PdoMysqlConnector.php index 8bd7b24..4228d36 100644 --- a/src/ORM/Connector/PdoMysqlConnector.php +++ b/src/ORM/Connector/PdoMysqlConnector.php @@ -33,6 +33,7 @@ public function getConnector(mixed $config): Connection 'port' => $config->port, 'driverClass' => Driver::class, 'charset' => $config->charset, + 'persistent' => $config->persistent, ], $this->getConfiguration(), $this->getEventManager()); } } \ No newline at end of file