Re: [PHP-PEAR] DB.php->parseDSN problem (bug?)

[email protected] (Joao Prado Maia) Wed, 28 Feb 2001 19:45:51 -0500 (EST)
Newsgroups php.pear
Message-ID <[email protected]>
On Thu, 1 Mar 2001, Tomas V.V.Cox wrote:

> Hi all again,
>
> During the tests of the ifx.php (informix pear DB class) I found one
> problem with the actual parseDSN function. One example for informix
> connect data is:
> user: foo
> pass: bar
> hostspec: host.com
> database: /usr/test/general.db
>
> So the DSN for that is:
> ifx://foo:[email protected]/usr/test/general.db
>
> The problem is that the actual regex:
> if (preg_match("|^(.*)/([^/]+)/?$|", $dsn, $arr)) {
>     $parsed["database"] = $arr[2];
>     $dsn = $arr[1];
> }
> Gets: general.db as the database and host.com/usr/test as the host, that
> is obviuosly wrong. Just for notice, probably in other evironments,
> database names could be: c:\dbs\foo.db.
>

You could make a work around this problem by sending the dsn as an array
instead of a string like you are doing now. Read DB.php for more on the
structure of this array.

Of course, the string method of passing dsn's is still a problem, but at
least you can code some stuff while this problem is being fixed.

Regards,
Joao

--
João Prado Maia <[email protected]>
http://phpbrasil.com - php com um jeitinho brasileiro
--
Contribua com o projeto de tradução do manual online do PHP
http://phpbrasil.com/traducao.php
--