php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42883 rowCount and ATTR_EMULATE_PREPARES fixed
Submitted: 2007-10-07 13:34 UTC Modified: 2007-10-19 21:07 UTC
From: salac dot r at gmail dot com Assigned:
Status: Closed Package: PDO related
PHP Version: 5.2.4 OS: openSUSE 10.2
Private report: No CVE-ID: None
 [2007-10-07 13:34 UTC] salac dot r at gmail dot com
Description:
------------
When I'm using ATTR_EMULATE_PREPARES set to true,
function rowCount returns bad result (0).
I think that it's quite strange because without ATTR_EMULATE_PREPARES it returns god values.

Reproduce code:
---------------
$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass,
array(    
    PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
    PDO::ATTR_EMULATE_PREPARES => true)
);
$result=$dbh->query("SELECT * FROM Table");
echo "rows = ".$result->rowCount();

Expected result:
----------------
rows = 7 //number of rows in Table

Actual result:
--------------
rows = 0

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-08 18:51 UTC] iliaa@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi

Seems to work fine for me. What version of MySQL are you using?
 [2007-10-08 21:31 UTC] salac dot r at gmail dot com
Well I'm not sure that I have enough skills to compile whole PHP but I do my best.:-)

I tried the code on 3 different.
PHP 5.2.0 MySQL 5.0.41 
PHP 5.2.4 MySQL 5.0.26
and
PHP 5.2.4 MySQL 5.0.32

on all machines it returned as a result Zero.
 [2007-10-12 18:48 UTC] mj@php.net
Works fine for me with 5.2.4, 5.3 and HEAD with MySQL 5.0.32.
 [2007-10-19 21:05 UTC] salac dot r at gmail dot com
Well, it works good now when I upgaraded Mysql on 5.0.45. So I think that problem is solved. Anyway thanks for good work, which you are doing.
 [2007-10-19 21:07 UTC] salac dot r at gmail dot com
fixed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 03:01:27 2024 UTC