note 11278 added to odbc_num_rows
| From: | shinelight at excite dot com | Date: | Wed, 14 Feb 2001 02:23:45 +0000 |
| Subject: | note 11278 added to odbc_num_rows | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-11033@lists.php.net to get a copy of this message | ||
A better method for calculating the record count (without being forced to use objects) is:
function RecordCount($sql_id, $CurrRow = 0)
{
$NumRecords = 0;
odbc_fetch_row($sql_id, 0);
while (odbc_fetch_row($sql_id))
{
$NumRecords++;
}
odbc_fetch_row($sql_id, $CurrRow);
return $NumRecords;
}
The only problem arises (in both this and the bit of code relying on objects) is when the driver
does not support fetching a specific row number. In that case, the query will have to be run again
(and cross your fingers that the data has not changed in the datasource).
http://www.php.net/manual/en/function.odbc-num-rows.php