]> granicus.if.org Git - php/commitdiff
* added Sebastian's affectedRows() and numRows() for MySQL
authorStig Bakken <ssb@php.net>
Thu, 7 Dec 2000 19:53:27 +0000 (19:53 +0000)
committerStig Bakken <ssb@php.net>
Thu, 7 Dec 2000 19:53:27 +0000 (19:53 +0000)
* added regression test for DB_mysql::affectedRows
* fixed some PEAR_Error based tests that had broken (line number change)

pear/DB.php
pear/tests/pear_error.phpt

index 3e6700de37601c89d7bac6c0a6d4855ac883073c..11e46b1497316fc7afbc903b0a0a5285dd50190b 100644 (file)
@@ -432,7 +432,8 @@ class DB_Error extends PEAR_Error
      */
 
     function DB_Error($code = DB_ERROR, $mode = PEAR_ERROR_RETURN,
-                     $level = E_USER_NOTICE, $debuginfo = null) {
+                     $level = E_USER_NOTICE, $debuginfo = null)
+    {
        if (is_int($code)) {
            $this->PEAR_Error("DB Error: " . DB::errorMessage( $code ), $code, $mode, $level, $debuginfo);
        } else {
@@ -463,7 +464,8 @@ class DB_Warning extends PEAR_Error
      */
 
     function DB_Warning($code = DB_WARNING, $mode = PEAR_ERROR_RETURN,
-                       $level = E_USER_NOTICE, $debuginfo = null) {
+                       $level = E_USER_NOTICE, $debuginfo = null)
+    {
       if (is_int($code)) {
          $this->PEAR_Error("DB Warning: " . DB::errorMessage( $code ), $code, $mode, $level, $debuginfo);
       } else {
@@ -491,7 +493,8 @@ class DB_result
      * @param   $result result resource id
      */
 
-    function DB_result(&$dbh, $result) {
+    function DB_result(&$dbh, $result)
+    {
        $this->dbh = &$dbh;
        $this->result = $result;
     }
@@ -500,7 +503,8 @@ class DB_result
      * Fetch and return a row of data.
      * @return  array   a row of data, or false on error
      */
-    function fetchRow($fetchmode = DB_FETCHMODE_DEFAULT) {
+    function fetchRow($fetchmode = DB_FETCHMODE_DEFAULT)
+    {
        if ($fetchmode == DB_FETCHMODE_DEFAULT) {
            $fetchmode = $this->dbh->fetchmode;
        }
@@ -513,7 +517,8 @@ class DB_result
      * @param   $arr    reference to data array
      * @return  int     error code
      */
-    function fetchInto(&$arr, $fetchmode = DB_FETCHMODE_DEFAULT) {
+    function fetchInto(&$arr, $fetchmode = DB_FETCHMODE_DEFAULT)
+    {
        if ($fetchmode == DB_FETCHMODE_DEFAULT) {
            $fetchmode = $this->dbh->fetchmode;
        }
@@ -523,17 +528,29 @@ class DB_result
     /**
      * Get the the number of columns in a result set.
      *
-     * @return int the number of columns, or a DB error code
+     * @return int the number of columns, or a DB error
      */
-    function numCols() {
+    function numCols()
+    {
        return $this->dbh->numCols($this->result);
     }
 
+    /**
+     * Get the number of rows in a result set.
+     *
+     * @return int the number of rows, or a DB error
+     */
+    function numRows()
+    {
+        return $this->dbh->numRows($this->result);
+    }
+
     /**
      * Frees the resources allocated for this result set.
      * @return  int     error code
      */
-    function free() {
+    function free()
+    {
        $err = $this->dbh->freeResult($this->result);
        if(DB::isError($err)) {
            return $err;
index 6c88b803da8ae453f301b12c577047cb437e6ce7..53f599af5ea8bce0858e1731a134b32bec3fbf9a 100644 (file)
@@ -89,16 +89,16 @@ mode=print: test error[pear_error: message="test error" code=-42 mode=print leve
 mode=callback(function): errorhandler function called, obj=[pear_error: message="test error" code=-42 mode=callback callback=errorhandler prefix="" prepend="" append="" debug=""]
 mode=callback(method): errorhandler method called, obj=[pear_error: message="test error" code=-42 mode=callback callback=errorclass::errorhandler prefix="" prepend="" append="" debug=""]
 mode=print&trigger: test error<br>
-<b>Notice</b>:  test error in <b>PEAR.php</b> on line <b>204</b><br>
+<b>Notice</b>:  test error in <b>PEAR.php</b> on line <b>206</b><br>
 [pear_error: message="test error" code=-42 mode=print|trigger level=notice prefix="" prepend="" append="" debug=""]
 mode=trigger: <br>
-<b>Notice</b>:  test error in <b>PEAR.php</b> on line <b>204</b><br>
+<b>Notice</b>:  test error in <b>PEAR.php</b> on line <b>206</b><br>
 [pear_error: message="test error" code=-42 mode=trigger level=notice prefix="" prepend="" append="" debug=""]
 mode=trigger,level=notice: <br>
-<b>Notice</b>:  test error in <b>PEAR.php</b> on line <b>204</b><br>
+<b>Notice</b>:  test error in <b>PEAR.php</b> on line <b>206</b><br>
 [pear_error: message="test error" code=-42 mode=trigger level=notice prefix="" prepend="" append="" debug=""]
 mode=trigger,level=warning: <br>
-<b>Warning</b>:  test error in <b>PEAR.php</b> on line <b>204</b><br>
+<b>Warning</b>:  test error in <b>PEAR.php</b> on line <b>206</b><br>
 [pear_error: message="test error" code=-42 mode=trigger level=warning prefix="" prepend="" append="" debug=""]
 mode=trigger,level=error: <br>
-<b>Fatal error</b>:  test error in <b>PEAR.php</b> on line <b>204</b><br>
+<b>Fatal error</b>:  test error in <b>PEAR.php</b> on line <b>206</b><br>