]> granicus.if.org Git - php/commitdiff
-Add getCode() method to PEAR_Error
authorSterling Hughes <sterling@php.net>
Thu, 24 Aug 2000 01:34:16 +0000 (01:34 +0000)
committerSterling Hughes <sterling@php.net>
Thu, 24 Aug 2000 01:34:16 +0000 (01:34 +0000)
-Correct license versions + My Address for DB/* mods
-Correct ibase module
-Javadocize File_Find
-Add a optional constructor to DB that passes it on to DB::connect()

pear/DB.php
pear/PEAR.php.in

index 2e53f79e6d1436c7a7afe79a4811a04893aef9df..d9b809ea69e495fec5734203ee76dc5f2893eaf5 100644 (file)
@@ -152,6 +152,14 @@ if (!defined('DB_GETMODE_DEFAULT')) {
  * @since    PHP 4.0
  */
 class DB {
+
+       function DB ($dsn = false, $persistent = false)
+       {
+               if ($dsn) {
+                       return DB::connect ($dsn, $persistent);
+               }
+       }
+
     // {{{ factory()
 
        /**
@@ -162,7 +170,7 @@ class DB {
         * @return object a newly created DB object, or a DB error code on
         * error
         */
-    function &factory($type) {
+       function &factory($type) {
                @include_once("DB/${type}.php");
                $classname = 'DB_' . $type;
                $obj = @new $classname;
@@ -170,7 +178,7 @@ class DB {
                        return new DB_Error(DB_ERROR_NOT_FOUND);
                }
                return $obj;
-    }
+       }
 
     // }}}
     // {{{ connect()
index b1b4182a9048c4e42197ff70e3c00ba56db92136..35753309260d5d438d615238d2cecbf4c6ebe049 100644 (file)
@@ -143,6 +143,7 @@ class PEAR_Error
        
        var $mode                 = PEAR_ERROR_RETURN;
        var $level                = E_USER_NOTICE;
+       var $code                 = -1;
        
        var $message              = '';
 
@@ -205,6 +206,19 @@ class PEAR_Error
        }
        
 
+    // }}}
+    // {{{ getCode()
+    
+       /**
+        * Get error code from an error object
+        *
+        * @return int error code
+        */
+        function getCode ()
+        {
+               return ($this->code);
+        }
+
     // }}}
     // {{{ getType()