Home » Database » DB » Bug #2673
DB::Connect fails to connect to PostgreSQL through UNIX socket.
Details
| Submitted | 2004-11-02 15:55 UTC |
|---|---|
| From | sdubrov at qwest dot com |
| Assigned | danielc |
| Status | Closed |
| Package | DB |
| PHP Version | 4.3.9 |
| OS | Solaris 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);