From: Stig Bakken Date: Mon, 16 Apr 2001 21:24:38 +0000 (+0000) Subject: * actually commit the stuff I said I had committed :-) X-Git-Tag: php-4.0.6RC1~403 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d3bb8325853af62a10bee5a4b626091a6529b265;p=php * actually commit the stuff I said I had committed :-) --- diff --git a/pear/DB.php b/pear/DB.php index 3384ec1c62..d9c410ec3f 100644 --- a/pear/DB.php +++ b/pear/DB.php @@ -207,10 +207,11 @@ class DB * DB_common::setOption for more information on connection * options. * - * @return object a newly created DB object, or a DB error code on - * error + * @return object a newly created DB connection object, or a DB + * error object on error * * @see DB::parseDSN + * @see DB::isError */ function &connect($dsn, $options = false) { @@ -221,9 +222,17 @@ class DB } $type = $dsninfo["phptype"]; - @include_once "DB/${type}.php"; - $classname = "DB_${type}"; - @$obj =& new $classname; + if (is_array($options) && isset($options["debug"]) && + $options["debug"] >= 2) { + // expose php errors with sufficient debug level + include_once "DB/${type}.php"; + $classname = "DB_${type}"; + $obj =& new $classname; + } else { + @include_once "DB/${type}.php"; + $classname = "DB_${type}"; + @$obj =& new $classname; + } if (!$obj) { return new DB_Error(DB_ERROR_NOT_FOUND); @@ -242,6 +251,7 @@ class DB $err = $obj->connect($dsninfo, $obj->getOption('persistent')); if (DB::isError($err)) { + $err->addUserInfo($dsn); return $err; } @@ -347,7 +357,7 @@ class DB } if (DB::isError($value)) { - $value = $value->code; + $value = $value->getCode(); } return $errorMessages[$value];