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:21
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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: phpbug at elitecoders dot com
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 11:01:29 2024 UTC