PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB » Bug #2673

DB::Connect fails to connect to PostgreSQL through UNIX socket.

Details

Submitted2004-11-02 15:55 UTC
Fromsdubrov at qwest dot com
Assigneddanielc
StatusClosed
PackageDB
PHP Version4.3.9
OSSolaris 9
Roadmaps(Not assigned)

Comments

[2004-11-02 15:55 UTC] sdubrov at qwest dot com

Description:
------------
If DSN is set to something like pgsql://user:password@unix(/tmp/.s.PGSQL.5432)/database DB::Connect fails to connect to database. If it's set to pgsql://user:password@tcp(localhost:5432)/database everything works fine. The bug did not exist in the version 1.5.0RC1.

Reproduce code:
---------------
$dsn = pgsql://user:password@unix(/tmp/.s.PGSQL.5432)/database;
$dbh = DB::connect($dsn);

if (DB::isError($dbh)) {die($dbh->getMessage());}

Expected result:
----------------
Connect to database.

Actual result:
--------------
DB Error: connect failed

[2005-02-15 17:53 UTC] sdubrov at qwest dot com

It turned out that there is nothing wrong with DB module itself. pg_connect function automatically adds socket name to the connect string so one shouldn't pass it with DSN string. Just pass a directory name where PostgreSQL keeps the opened Socket or nothing if it's in the default /tmp. Like that:

$dsn = pgsql://user:password@unix(/tmp)/database;
$dbh = DB::connect($dsn);