|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-12-03 08:29 UTC] 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"
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 03:00:01 2025 UTC |
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");