Bug #18066 Updated: Data source name (DSN) parsing bug + FIX

From: Date: Sun, 30 Jun 2002 22:12:56 +0000
Subject: Bug #18066 Updated: Data source name (DSN) parsing bug + FIX
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-7422@lists.php.net to get a copy of this message
ID: 18066 Updated by: tim-phpbug@bitgems.com Reported By: tim-phpbug@bitgems.com Status: Bogus Bug Type: PEAR related Operating System: Linux Trustix PHP Version: 4.2.1 New Comment: Thanks for a quick response. I'll change my configuration to use the new format now that I know about it. What would be really helpful is if the new format were mentioned in the comment for parseDSN--that was what I was looking at for documentation. Previous Comments: ------------------------------------------------------------------------ [2002-06-30 14:01:00] cox@php.net From http://pear.php.net/manual/en/core.db.tut_dsn.php: With an up-to-date version of DB, you can use a second DSN format phptype(syntax)://user:pass@protocol(proto_opts)/database example: Connect to database through a socket mysql://user@unix(/path/to/socket)/pear Connect to database on a non standard port pgsql://user:pass@word@tcp(localhost:5555)/pear Tomas V.V.Cox PS.- You can use pear-dev@lists.php.net for reporting bugs or pear-general@lists.php.net for support questions ------------------------------------------------------------------------ [2002-06-29 15:39:47] tim-phpbug@bitgems.com I'm using a DSN of the format: mysql://database:password@localhost:/path/to/port/mysql.sock/squirrel Which seemed like it should work, but it fails because of the way PEAR parses the DSN: Instead of looking for the last / to deliniate the database, it looks for the first. I changed the following lines in DB.php, in the function parseDSN, at line 502: ... if (strpos($dsn, '/') !== false) { // **THM** $offset = strrpos($dsn,'/') ; $proto_opts = substr($dsn,0,$offset) ; $dsn = substr($dsn,$offset+1); // old: list($proto_opts, $dsn) = explode('/', $dsn, 2); } else { ... This fixes the problem and should remain compatible with numeric ports as well. A quick scan of the web site didn't reveal how to submit patches, so I hope this is Kosher. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=18066&edit=1

« previous php.pear.dev (#7422) next »