Re: Re: pear-db dsn and mysql sockets (patch)

From: Date: Sat, 12 Jan 2002 07:39:55 +0000
Subject: Re: Re: pear-db dsn and mysql sockets (patch)
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-3912@lists.php.net to get a copy of this message
Good Morning :) Made a quick hack to get mysql-sockets work in parseDSN. I'm not sure, if it supports every allowed dsn, but now it takes either the first // as the hostspec/database delimiter (to allow a dsn like phptype://username:password@protocol+hostspec:110//usr/db_file.db) or the last / (the more common thing). I hope, I didn't screw up anything, but before i commit i'd like to know, what the main DB-Maintainer think of it. here's the patch Index: DB.php =================================================================== RCS file: /repository/php4/pear/DB.php,v retrieving revision 1.81 diff -u -r1.81 DB.php --- DB.php 13 Dec 2001 23:07:16 -0000 1.81 +++ DB.php 12 Jan 2002 07:35:13 -0000 @@ -483,7 +483,12 @@ // Find protocol and hostspec // $dsn => protocol+hostspec/database - if (($pos=strpos($dsn, '/')) !== false) { + // - take the first // as the hostspec/db-delimiter + if (($pos=strpos($dsn, '//')) !== false) { + $str = substr($dsn, 0, $pos); + $dsn = substr($dsn, $pos + 2); + // or else take the last as the hostspec/db-delimiter + } elseif (($pos=strrpos($dsn, '/')) !== false) { $str = substr($dsn, 0, $pos); $dsn = substr($dsn, $pos + 1); } else { chregu > In <pan.2002.01.11.23.59.31.569001.4708@php.net>, Christian Stocker wrote: > > > Hi > > > > Is it possible to use a mysql-socket file as a connection parameter in > > pear-db? The obvious (?) > > mysql://user@localhost:/path/to/mysqld.sock/database does not work. > > > oops. I should not write mails, when i'm really toooo tired. the question > was asked here a few days ago and there was no answer :( maybe then we > should implement it. so, here a little discussion. > > normal way of calling the dsn is > > mysql://user@localhost:port/database > > the socket way like in mysql_connect would be: > > mysql://user@localhost:/path/to/mysqld.sock/database > > but then. $parsed['database'] is "path/to/mysqld.sock/database" > > if we rewrite parseDSN to just take the name after the last / as the > database and everything before for the port/socker stuff (if there's a > colon), are we getting problems with other possibilities of the dsn in > other rdbms or would this a safe way to do? > > chregu > > -- nam...christian stocker adr...bremgartnerstr. 66, ch-8003 zurich pho...+41 1 451 6021 www...http://phant.ch/chregu mob...+41 76 561 8860 ema...chregu@phant.ch wor...+41 1 240 5670 gpg...0x5CE1DECB

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