From 1cb07caf6308efb06ce7341a54391354bb8a92de Mon Sep 17 00:00:00 2001 From: "Tomas V.V.Cox" Date: Fri, 1 Feb 2002 15:03:17 +0000 Subject: [PATCH] Added support for passing special backend params in DSN. Ex: ibase://user:pass@localhost/db?role=foo&dialect=bar --- pear/DB.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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; -- 2.50.1