From 8f74a368582a6e2094e89454e203ade0420f2efe Mon Sep 17 00:00:00 2001 From: Stig Bakken Date: Thu, 7 Dec 2000 19:53:27 +0000 Subject: [PATCH] * added Sebastian's affectedRows() and numRows() for MySQL * added regression test for DB_mysql::affectedRows * fixed some PEAR_Error based tests that had broken (line number change) --- pear/DB.php | 33 +++++++++++++++++++++++++-------- pear/tests/pear_error.phpt | 10 +++++----- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/pear/DB.php b/pear/DB.php index 3e6700de37..11e46b1497 100644 --- a/pear/DB.php +++ b/pear/DB.php @@ -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; diff --git a/pear/tests/pear_error.phpt b/pear/tests/pear_error.phpt index 6c88b803da..53f599af5e 100644 --- a/pear/tests/pear_error.phpt +++ b/pear/tests/pear_error.phpt @@ -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
-Notice: test error in PEAR.php on line 204
+Notice: test error in PEAR.php on line 206
[pear_error: message="test error" code=-42 mode=print|trigger level=notice prefix="" prepend="" append="" debug=""] mode=trigger:
-Notice: test error in PEAR.php on line 204
+Notice: test error in PEAR.php on line 206
[pear_error: message="test error" code=-42 mode=trigger level=notice prefix="" prepend="" append="" debug=""] mode=trigger,level=notice:
-Notice: test error in PEAR.php on line 204
+Notice: test error in PEAR.php on line 206
[pear_error: message="test error" code=-42 mode=trigger level=notice prefix="" prepend="" append="" debug=""] mode=trigger,level=warning:
-Warning: test error in PEAR.php on line 204
+Warning: test error in PEAR.php on line 206
[pear_error: message="test error" code=-42 mode=trigger level=warning prefix="" prepend="" append="" debug=""] mode=trigger,level=error:
-Fatal error: test error in PEAR.php on line 204
+Fatal error: test error in PEAR.php on line 206
-- 2.50.1