]> granicus.if.org Git - php/commitdiff
Multiple DB::connect or DB::factory calls using the same backend
authorStig Bakken <ssb@php.net>
Wed, 26 Jul 2000 09:57:06 +0000 (09:57 +0000)
committerStig Bakken <ssb@php.net>
Wed, 26 Jul 2000 09:57:06 +0000 (09:57 +0000)
should work now.

pear/DB.php

index 5a70356fd1dfc27fe4fad261667259ec32f71d6a..97e0f7077a033d121d48596f738f4fe715362102 100644 (file)
@@ -163,11 +163,12 @@ class DB {
         * error
         */
     function &factory($type) {
-               if (!@include_once("DB/${type}.php")) {
-                       return DB_ERROR_NOT_FOUND;
-               }
+               @include_once("DB/${type}.php");
                $classname = 'DB_' . $type;
-               $obj = new $classname;
+               $obj = @new $classname;
+               if (!$obj) {
+                       return new DB_Error(DB_ERROR_NOT_FOUND);
+               }
                return $obj;
     }
 
@@ -192,11 +193,12 @@ class DB {
 
                $dsninfo = DB::parseDSN($dsn);
                $type = $dsninfo['phptype'];
-               if (!@include_once("DB/${type}.php")) {
-                       return DB_ERROR_NOT_FOUND;
-               }
+               @include_once("DB/${type}.php");
                $classname = 'DB_' . $type;
-               $obj = new $classname;
+               $obj = @new $classname;
+               if (!$obj) {
+                       return new DB_Error(DB_ERROR_NOT_FOUND);
+               }
                $err = $obj->connect(&$dsninfo, $persistent);
                if (DB::isError($err)) {
                        return $err;