From: Stig Bakken Date: Thu, 19 Apr 2001 02:32:33 +0000 (+0000) Subject: * added Colin's connect/factory error reporting fix X-Git-Tag: php-4.0.6RC1~375 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ad8dbb8d10839749a9a96bd33989e388cae80069;p=php * added Colin's connect/factory error reporting fix --- diff --git a/pear/DB.php b/pear/DB.php index b35f51adbe..b5054971ba 100644 --- a/pear/DB.php +++ b/pear/DB.php @@ -185,13 +185,14 @@ class DB @include_once("DB/${type}.php"); $classname = "DB_${type}"; - @$obj =& new $classname; - if (!$obj) { + if (!class_exists($classname)) { return PEAR::raiseError(DB_ERROR_NOT_FOUND, null, null, null, null, 'DB_Error', true); } + @$obj =& new $classname; + return $obj; } @@ -227,19 +228,18 @@ class DB $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) { + $classname = "DB_${type}"; + if (!class_exists($classname)) { return PEAR::raiseError(DB_ERROR_NOT_FOUND, null, null, null, null, 'DB_Error', true); } + @$obj =& new $classname; + if (is_array($options)) { foreach ($options as $option => $value) { $test = $obj->setOption($option, $value);