mirror of
https://github.com/dg/dibi.git
synced 2025-08-08 07:06:52 +02:00
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
This commit is contained in:
@@ -23,6 +23,7 @@ use Dibi\Helpers;
|
|||||||
* - charset => character encoding to set (default is utf8)
|
* - charset => character encoding to set (default is utf8)
|
||||||
* - persistent (bool) => try to find a persistent link?
|
* - persistent (bool) => try to find a persistent link?
|
||||||
* - resource (resource) => existing connection resource
|
* - resource (resource) => existing connection resource
|
||||||
|
* - connect_type (int) => see pg_connect()
|
||||||
*/
|
*/
|
||||||
class PostgreDriver implements Dibi\Driver
|
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) {
|
set_error_handler(function (int $severity, string $message) use (&$error) {
|
||||||
$error = $message;
|
$error = $message;
|
||||||
});
|
});
|
||||||
if (empty($config['persistent'])) {
|
if (empty($config['persistent'])) {
|
||||||
$this->connection = pg_connect($string, PGSQL_CONNECT_FORCE_NEW);
|
$this->connection = pg_connect($string, $connectType);
|
||||||
} else {
|
} else {
|
||||||
$this->connection = pg_pconnect($string);
|
$this->connection = pg_pconnect($string, $connectType);
|
||||||
}
|
}
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user