PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB » Bug #3228

need to be able to supply connect_timeout to pgsql::connect

Details

Request #3228need to be able to supply connect_timeout to pgsql::connect
Submitted2005-01-18 14:50 UTC
Fromterminus at local dot ee
Assigneddanielc
StatusClosed
PackageDB
PHP Version4.3.10
Roadmaps(Not assigned)

Comments

[2005-01-18 14:50 UTC] terminus at local dot ee

Description:
------------
The $dsninfo parameter in DB/pgsql.php is hardwired to parameters protocol, hostspec, port, database, username, password, options, tty. When I need to also supply the connect_timeout parameter, my only option currently is to make an evil hack and hardcode it into pgsql.php. I'd rather supply it as normal DSN parameter.

[2005-01-18 16:20 UTC] terminus at local dot ee

"normal DSN parameter" means that I'd be able to supply it as a key/value pair in the DSN array. The connect_timeout doesnt seem to fit well into the DSN string schema, so need not be supported there.

[2005-01-31 17:39 UTC] terminus at local dot ee

You are not seeing the timeout parameter on the doc page because its not there :) the pg_connect accepts a "connection string" and I assume it passes on to the PostgreSQL library in fairly vanilla format. If it eats out the connect_timeout, it shouldnt. You can find it here: http://www.postgresql.org/docs/current/static/libpq.html#LIBPQ-CONNECT

The evil hack was simply to hardcode:
$connstr .= ' connect_timeout=5';
in DB/pgsql.php. However, a clean way of doing this would be simply to add in the connect() function the following:

if (isset($dsninfo['connect_timeout'])) {
$connstr .= ' connect_timeout=' . $dsninfo['connect_timeout'];
}

[2005-01-31 17:41 UTC] terminus at local dot ee

See also http://archives.postgresql.org/pgsql-php/2004-02/msg00042.php