note 58744 added to function.mysql-num-rows
| From: | manciniatnextcodedotorg at osu1 dot php dot net | Date: | Mon, 14 Nov 2005 21:24:56 +0000 |
| Subject: | note 58744 added to function.mysql-num-rows | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98558@lists.php.net to get a copy of this message | ||
here is a really fast mysql_num_rows alternative that makes use of the SELECT FOUND_ROWS() MySQL
function , it only reads a single row and it is really helpfull if you are counting multiple tables
with thousands of rows
<?php
function get_rows ($table) {
$temp = mysql_query("SELECT SQL_CALC_FOUND_ROWS * FROM $table LIMIT 1");
$result = mysql_query("SELECT FOUND_ROWS()");
$total = mysql_fetch_row($result);
return $total[0];
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.mysql-num-rows.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58744
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58744&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58744&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58744&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58744&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58744&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58744&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58744&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58744&report=yes
Search -- http://master.php.net/manage/user-notes.php