ID: 35529
Updated by: [EMAIL PROTECTED]
Reported By: nitinvaishnav at gmail dot com
Status: Bogus
Bug Type: PDO related
Operating System: windows 2000
PHP Version: 5.1.1
New Comment:
count($Result) will give you the answer you're looking for.
Previous Comments:
------------------------------------------------------------------------
[2005-12-03 19:29:01] nitinvaishnav at gmail dot com
thanks for information.
but following code also not work properly, the second rowCount also
returns 0.
$Con = new PDO('mysql:host=localhost;dbname=nitin', 'root', '');
$Res = $Con->query('select * from test',
array(PDO_MYSQL_ATTR_USE_UNBUFFERED_QUERY => true));
echo('1. rowCount: ' . $Res->rowCount() . "\n\n");
$Result = $Res->fetchAll();
var_dump($Result);
echo('2. rowCount: ' . $Res->rowCount() . "\n\n");
------------------------------------------------------------------------
[2005-12-03 17:24:22] [EMAIL PROTECTED]
PDO uses forward-only unbuffered cursors.
The row count is not know until all the rows have been retrieved.
See http://netevil.org/node.php?nid=703&SC=1#comments
for more information.
------------------------------------------------------------------------
[2005-12-03 13:07:40] [EMAIL PROTECTED]
Please try using this CVS snapshot:
http://snaps.php.net/php5.1-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.1-win32-latest.zip
------------------------------------------------------------------------
[2005-12-03 08:30:45] nitinvaishnav at gmail dot com
I using php 5.1.1 on IIS with mysql 4.1.10a. The test database have 3
rows, the rowCount function returns 0, but foreach dumps 3 records of
the table. But the rowCount returns correct result with INSERT, UPDATE
and DELETE.
------------------------------------------------------------------------
[2005-12-03 08:29:23] nitinvaishnav at gmail dot com
Description:
------------
I using php 5.1.1 on IIS with 4.1.10a. The test database have 3 rows,
the rowCount function returns 0, but foreach dumps 3 records of the
table. But the rowCount returns correct result with INSERT, UPDATE and
DELETE.
Reproduce code:
---------------
$Con = new PDO('mysql:host=localhost;dbname=nitin', 'root', '');
$Res = $Con->query('select * from test');
echo('rowCount: ' . $Res->rowCount() . "\n\n");
foreach ($Res as $Record) {
var_dump($Record);
}
Expected result:
----------------
rowCount: 3
array(2) {
["test_int1"]=>
string(1) "1"
[0]=>
string(1) "1"
}
array(2) {
["test_int1"]=>
string(1) "1"
[0]=>
string(1) "1"
}
array(2) {
["test_int1"]=>
string(1) "1"
[0]=>
string(1) "1"
}
Actual result:
--------------
rowCount: 0
array(2) {
["test_int1"]=>
string(1) "1"
[0]=>
string(1) "1"
}
array(2) {
["test_int1"]=>
string(1) "1"
[0]=>
string(1) "1"
}
array(2) {
["test_int1"]=>
string(1) "1"
[0]=>
string(1) "1"
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35529&edit=1