|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23720 DB::Connect does not accept string for $dsn when using pgsql
Submitted: 2003-05-20 10:01 UTC Modified: 2003-05-20 10:44 UTC
From: brian at onlineinfo dot net Assigned: lsmith (profile)
Status: Closed Package: PEAR related
PHP Version: 4.3.1 OS: Debian, Solaris
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: brian at onlineinfo dot net
New email:
PHP Version: OS:


 [2003-05-20 10:01 UTC] brian at onlineinfo dot net
When passing a valid DSN to DB::Connect and connecting to pgsql, DB_Pgsql expects the dsn to be an array instead of a string.  The result is a broken connect string since PHP will happily treat the string as an array.  The solution is to replace:

$this->dsn = $dsninfo;


if (is_array($dsninfo)) {
    $this->dsn = $dsninfo;
} else {
    $this->dsn = $dsninfo = DB::parseDSN($dsninfo);

in the connect method of DB/pgsql.php.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-20 10:12 UTC]
Are you trying to switch the dsn after object creation with the factory method? This feature is not supported as far as I know.

DB_pgsql::connect() should not be called by the user.
 [2003-05-20 10:23 UTC] brian at onlineinfo dot net
Here is the connect code we are using:

    $db = DB::factory('pgsql_ex');
    if (DB::isError($db)) return $db;
    $connect = $db->Connect($dsn, $persistent = TRUE);
    if (DB::isError($connect)) return $connect;
    return $db;

(pgsql_ex is a small class extending DB_pgsql that adds a metadata method)
 [2003-05-20 10:44 UTC]
this is the expected behavior. You should be able to use DB::connect() with your custom class, which handles string dsn and options for convinience. 
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Mar 21 05:03:38 2023 UTC