port enabled DSN for DB/pgsql.php
| From: | KOYAMA Tetsuji | Date: | Mon, 04 Dec 2000 07:28:40 +0000 |
| Subject: | port enabled DSN for DB/pgsql.php | ||
| Groups: | php.pear | ||
| Request: | Send a blank email to php-pear+get-483@lists.php.net to get a copy of this message | ||
Hi,
I try to connect to PostgreSQL DB via non standard port. But it was
seemed for me that DB::parseDSN() can't parse 'port' variable. And
the only class depended 'port' variable is DB_pgsql.
So, I make patch for DB/pgsql.php to understand port number from DSN.
If apply this patch, it's enalbe following syntaxes:
'pgsql://user:pass@host:port/dbname'
'pgsql://user:pass@host/dbname'
'pgsql://user:pass@:port/dbname'
But not works following:
'pgsql://host:port/dbname'
-- 'host:port' parsed as 'user:pass'
--- /var/anon-cvs/php4/pear/DB/pgsql.php Tue Sep 26 23:23:54 2000
+++ pgsql.php Mon Dec 4 16:05:14 2000
@@ -105,6 +105,10 @@
$options = $dsninfo['options'];
$tty = $dsninfo['tty'];
$port = $dsninfo['port'] ? $dsninfo['port'] : '5432';
+ if (preg_match( '|^([^:]*):(.*)|', $dbhost, $arr )) {
+ $dbhost = $arr[1];
+ $port = $arr[2];
+ }
$connect_function = $persistent ? 'pg_pconnect' : 'pg_connect';
Regards,
--
koyama@hoge.org
koyama@beatraft.com
KOYAMA Tetsuji BeatCraft, Inc., Tokyo, Japan.