如何使用 DBAL 传递额外的连接选项,如 connect_timeout、keepalives等?
它应该作为driverOptions
或为明确支持而创建的拉取请求传递Doctrine\DBAL\Driver\PDOPgSql\Driver
吗?
我尝试通过 via 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 的配置,我不会收到这样的错误。