php.net |  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
Votes:20
Avg. Score:4.2 ± 1.1
Reproduced:12 of 15 (80.0%)
Same Version:2 (16.7%)
Same OS:0 (0.0%)
From: phpbug at elitecoders dot com Assigned: georg
Status: Wont fix Package: MySQL related
PHP Version: 5.0.4 OS: OS X
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2005-05-12 22:37 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

 [2005-06-20 06:21 UTC] georg@php.net
Unless we integrate a parser in ext/mysql for parsing mysql commands there is no way to fix it.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Mon Apr 21 12:02:07 2014 UTC