From: Tomas V.V.Cox Date: Fri, 1 Feb 2002 15:03:17 +0000 (+0000) Subject: Added support for passing special backend params in DSN. Ex: X-Git-Tag: PRE_ISSET_PATCH~28 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1cb07caf6308efb06ce7341a54391354bb8a92de;p=php Added support for passing special backend params in DSN. Ex: ibase://user:pass@localhost/db?role=foo&dialect=bar --- 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;