diff options
author | Stig Bakken <ssb@php.net> | 2000-12-07 19:53:27 +0000 |
---|---|---|
committer | Stig Bakken <ssb@php.net> | 2000-12-07 19:53:27 +0000 |
commit | 8f74a368582a6e2094e89454e203ade0420f2efe (patch) | |
tree | 15ac38ab33b4e0165d72c10b8ecabad13e8b2c11 | |
parent | acdae3a14931bfa926655e3159140741d27cf544 (diff) | |
download | php-git-8f74a368582a6e2094e89454e203ade0420f2efe.tar.gz |
* 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)
-rw-r--r-- | pear/DB.php | 33 | ||||
-rw-r--r-- | 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<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> |