【问题标题】:DBAL: Pass extra connection options to pdo_pgsqlDBAL:将额外的连接选项传递给 pdo_pgsql
【发布时间】:2015-03-10 12:20:36
【问题描述】:

如何通过 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 的配置,我不会收到此类错误。

【问题讨论】:

  • DBAL:学说/dbal 2.3.5

标签: php dbal


【解决方案1】:

目前显然不支持此功能。所有额外的选项都应该明确添加到PDOPgSql/Driver.php

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-26
    • 1970-01-01
    • 2022-07-07
    • 2017-11-04
    • 1970-01-01
    • 1970-01-01
    • 2018-10-07
    • 1970-01-01
    相关资源
    最近更新 更多