ID: 33021
Updated by: [EMAIL PROTECTED]
Reported By: phpbug at elitecoders dot com
-Status: Open
+Status: Assigned
Bug Type: MySQL related
Operating System: OS X
PHP Version: 5.0.4
-Assigned To:
+Assigned To: georg
New Comment:
Georg, check this out..
Previous Comments:
------------------------------------------------------------------------
[2005-05-12 22:37:00] phpbug at elitecoders dot com
Description:
------------
When the php.ini "mysql.trace_mode" option is set to true,
and you do a mysql_query with SQL_CALC_FOUND_ROWS,
the result of a SELECT FOUND_ROWS() will always be 1, no matter how
many rows would have been returned (disregarding any LIMIT clause.)
changing mysql.trace_mode to false will make it return the correct
number.
Reproduce code:
---------------
ini_set('mysql.trace_mode', true);
$result_id = mysql_query('SELECT SQL_CALC_FOUND_ROWS column FROM t
LIMIT 5');
$rows = array();
while($row = mysql_fetch_assoc($result_id)) {
$rows[] = $row;
}
$result_id = mysql_query('SELECT FOUND_ROWS()');
list($row_total) = mysql_fetch_row($result_id);
Expected result:
----------------
$row_total will be the number of rows returned if there were no LIMIT
clause.
Actual result:
--------------
$row_total is 1, regardless of the actual found rows.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33021&edit=1