|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33021 SQL_CALC_FOUND_ROWS and mysql.trace_mode=true always returns 1
Submitted: 2005-05-12 22:37 UTC Modified: 2005-06-20 06:21 UTC
Avg. Score:4.2 ± 1.1
Reproduced:13 of 16 (81.2%)
Same Version:2 (15.4%)
Same OS:1 (7.7%)
From: phpbug at elitecoders dot com Assigned: georg (profile)
Status: Wont fix Package: MySQL related
PHP Version: 5.0.4 OS: OS X
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2005-05-12 22:37 UTC] phpbug at elitecoders dot com
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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-27 08:57 UTC]
Georg, check this out..

 [2005-06-20 06:21 UTC]
Unless we integrate a parser in ext/mysql for parsing mysql commands there is no way to fix it.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jul 12 11:01:32 2024 UTC