]> granicus.if.org Git - php/commitdiff
* actually commit the stuff I said I had committed :-)
authorStig Bakken <ssb@php.net>
Mon, 16 Apr 2001 21:24:38 +0000 (21:24 +0000)
committerStig Bakken <ssb@php.net>
Mon, 16 Apr 2001 21:24:38 +0000 (21:24 +0000)
pear/DB.php

index 3384ec1c6260ec549c318716bfa85895a24b2687..d9c410ec3f9296b170e3eb0cf3ddc7b0e0cb4c40 100644 (file)
@@ -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];