From cc3712139067f854a9a08e69fa9320b1831cca97 Mon Sep 17 00:00:00 2001 From: groupnet Date: Thu, 8 Oct 2020 15:34:38 +0200 Subject: [PATCH] Postgre driver - add connect_type config parameter (#370) - adds the option to pass the connect_type as config parameter - PHP default is 0, but to make this change non-breaking defauls to PGSQL_CONNECT_FORCE_NEW - see PHP docs: https://www.php.net/manual/en/function.pg-connect.php --- src/Dibi/Drivers/PostgreDriver.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Dibi/Drivers/PostgreDriver.php b/src/Dibi/Drivers/PostgreDriver.php index 2f79e908..1c25296a 100644 --- a/src/Dibi/Drivers/PostgreDriver.php +++ b/src/Dibi/Drivers/PostgreDriver.php @@ -23,6 +23,7 @@ use Dibi\Helpers; * - charset => character encoding to set (default is utf8) * - persistent (bool) => try to find a persistent link? * - resource (resource) => existing connection resource + * - connect_type (int) => see pg_connect() */ class PostgreDriver implements Dibi\Driver { @@ -62,14 +63,15 @@ class PostgreDriver implements Dibi\Driver } } } + $connectType = $config['connect_type'] ?? PGSQL_CONNECT_FORCE_NEW; set_error_handler(function (int $severity, string $message) use (&$error) { $error = $message; }); if (empty($config['persistent'])) { - $this->connection = pg_connect($string, PGSQL_CONNECT_FORCE_NEW); + $this->connection = pg_connect($string, $connectType); } else { - $this->connection = pg_pconnect($string); + $this->connection = pg_pconnect($string, $connectType); } restore_error_handler(); }