DBAL:将额外的连接选项传递给 pdo_pgsql
DBAL: Pass extra connection options to pdo_pgsql
如何通过 DBAL 传递额外的连接选项,例如 connect_timeout、keepalives、etc..?
它应该作为 driverOptions
传递还是在 Doctrine\DBAL\Driver\PDOPgSql\Driver
处为明确支持而创建的拉取请求?
我尝试通过driverOptions => ['connect_timeout' => 1]
,但不确定这些设置是否有效。当我使用普通 pdo_connect
调用时:
$connectionString = 'host=... connect_timeout=1 keepalives=1 keepalives_idle=2 keepalives_interval=1 keepalives_count=2'
$connection = pg_connect($connectionString);
我知道至少应用了这些设置,因为如果我拼错了任何这些额外参数,则会引发异常:
$connectionString = 'host=... connection_timeout=1'
$connection = pg_connect($connectionString);
PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: invalid connection option "connection_timeout" in /troubleshoot/psql.php on line 18
这个异常是我检查是否应用了这个设置的方式。
不过,如果我拼错传递给 DBAL 的配置,我不会收到此类错误。
目前显然不支持。所有额外选项都应显式添加到 PDOPgSql/Driver.php.
如何通过 DBAL 传递额外的连接选项,例如 connect_timeout、keepalives、etc..?
它应该作为 driverOptions
传递还是在 Doctrine\DBAL\Driver\PDOPgSql\Driver
处为明确支持而创建的拉取请求?
我尝试通过driverOptions => ['connect_timeout' => 1]
,但不确定这些设置是否有效。当我使用普通 pdo_connect
调用时:
$connectionString = 'host=... connect_timeout=1 keepalives=1 keepalives_idle=2 keepalives_interval=1 keepalives_count=2'
$connection = pg_connect($connectionString);
我知道至少应用了这些设置,因为如果我拼错了任何这些额外参数,则会引发异常:
$connectionString = 'host=... connection_timeout=1'
$connection = pg_connect($connectionString);
PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: invalid connection option "connection_timeout" in /troubleshoot/psql.php on line 18
这个异常是我检查是否应用了这个设置的方式。
不过,如果我拼错传递给 DBAL 的配置,我不会收到此类错误。
目前显然不支持。所有额外选项都应显式添加到 PDOPgSql/Driver.php.