mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 06:07:39 +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)
|
||||
* - 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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user