diff options
author | Tomas V.V.Cox <cox@php.net> | 2002-02-01 15:03:17 +0000 |
---|---|---|
committer | Tomas V.V.Cox <cox@php.net> | 2002-02-01 15:03:17 +0000 |
commit | 1cb07caf6308efb06ce7341a54391354bb8a92de (patch) | |
tree | 1cecaff3d54961939c3af4d1f79be06d32fa4093 /pear | |
parent | 4526dd2078f18584848eee96b946e0a193db05c1 (diff) | |
download | php-git-1cb07caf6308efb06ce7341a54391354bb8a92de.tar.gz |
Added support for passing special backend params in DSN. Ex:
ibase://user:pass@localhost/db?role=foo&dialect=bar
Diffstat (limited to 'pear')
-rw-r--r-- | pear/DB.php | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/pear/DB.php b/pear/DB.php index 71d0a5ca9b..05c871f701 100644 --- a/pear/DB.php +++ b/pear/DB.php @@ -520,7 +520,23 @@ class DB // Get dabase if any // $dsn => database if (!empty($dsn)) { - $parsed['database'] = $dsn; + // /database + if (($pos = strpos($dsn, '?')) === false) { + $parsed['database'] = $dsn; + // /database?param1=value1¶m2=value2 + } else { + $parsed['database'] = substr($dsn, 0, $pos); + $dsn = substr($dsn, $pos + 1); + if (strpos($dsn, '&') !== false) { + $opts = explode('&', $dsn); + } else { // database?param1=value1 + $opts = array($dsn); + } + foreach ($opts as $opt) { + list($key, $value) = explode('=', $opt); + $parsed[$key] = urldecode($value); + } + } } return $parsed; |