]> granicus.if.org Git - php/commitdiff
* applied fetch modes patch for odbc by Richard M. Yumul
authorStig Bakken <ssb@php.net>
Fri, 8 Dec 2000 02:30:43 +0000 (02:30 +0000)
committerStig Bakken <ssb@php.net>
Fri, 8 Dec 2000 02:30:43 +0000 (02:30 +0000)
* added DB::isManip so we have _one_ place for testing whether something
  is a data manipulation query
* when passed a string as its first constructor arg, DB_Error now uses
  the error code DB_ERROR rather than just 0
* implemented auto-commit for ibase (not yet fully tested)
* fixed persistent connections in odbc

pear/DB.php

index 11e46b1497316fc7afbc903b0a0a5285dd50190b..5bddb607fe9d6fd7407e8dd1d22e64cc0851258f 100644 (file)
@@ -247,6 +247,24 @@ class DB
             is_subclass_of($value, "db_error"));
     }
 
+    /**
+     * Tell whether a query is a data manipulation query (insert, update
+     * or delete).
+     *
+     * @access public
+     *
+     * @param string the query
+     *
+     * @return bool whether $query is a data manipulation query
+     */
+    function isManip($query)
+    {
+        if (preg_match('/^\s*(INSERT|UPDATE|DELETE)\s+/i', $query)) {
+            return true;
+        }
+        return false;
+    }
+
     /**
      * Tell whether a result code from a DB method is a warning.
      * Warnings differ from errors in that they are generated by DB,
@@ -437,7 +455,7 @@ class DB_Error extends PEAR_Error
        if (is_int($code)) {
            $this->PEAR_Error("DB Error: " . DB::errorMessage( $code ), $code, $mode, $level, $debuginfo);
        } else {
-           $this->PEAR_Error("DB Error: $code", 0, $mode, $level, $debuginfo);
+           $this->PEAR_Error("DB Error: $code", DB_ERROR, $mode, $level, $debuginfo);
        }
     }
 }