numRows()
| From: | Sebastian Bergmann | Date: | Thu, 07 Dec 2000 17:34:47 +0000 |
| Subject: | numRows() | ||
| Groups: | php.pear | ||
| Request: | Send a blank email to php-pear+get-603@lists.php.net to get a copy of this message | ||
I'd like to propose the following patch in order to introduce a numRows()
method in general and adds affectedRows() functionality for the mysql
module:
- DB.php
/**
* Get the the number of rows in a result set.
*
* @return int the number of rows, or a DB error code
*/
function numRows() {
return $this->dbh->numRows($this->result);
}
- mysql.php
/**
* Get the number of rows in a result set.
*
* @param $result MySQL result identifier
*
* @access public
*
* @return int the number of rows in $result
*/
function numRows($result) {
$rows = mysql_num_rows($result);
if (!$rows) {
return
$this->raiseError($this->errorCode(
mysql_errno($this->connection)));
}
return $rows;
}
/**
* Gets the number of rows affected by the last query.
* if the last query was a select, returns 0.
*
* @return number of rows affected by the last query or DB_ERROR
*/
function affectedRows() {
$result = mysql_affected_rows($this->connection);
// do we need to perform checks on $result here?
return $result;
}
--
<? print implode( "", array_reverse( preg_split( "//", "dlrow laer
" .
"eht ot emoclew" ) ) ); /* visit http://www.sebastian-bergmann.de/ */ ?>