|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-02-15 07:39 UTC] edink at emini dot dk
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 06:00:01 2025 UTC |
Description: ------------ Hi The following pdo code for pgsql: a. creates table b. inserts 2 records c. counts number of recs d. displays records Notice that the count of records returned is NULL, when it should be 2. Thanks, John PS: Am running Postgresql 8.0. Reproduce code: --------------- <?php error_reporting(E_ALL); echo "<pre>"; $connstr = "pgsql:dbname=test";$u = 'test'; $p = 'test'; $db = new PDO($connstr,$u,$p); $db->query('create table abc (x varchar(32))'); $db->query('delete from abc'); $db->query("insert into abc values ('abc')"); $db->query("insert into abc values ('def')"); echo "<h3>Count</h3>"; $stmt = $db->query('select count(*) from abc'); var_dump($stmt->fetch()); echo "<h3>Select</h3>"; $stmt = $db->query('select * from abc'); while ($arr = $stmt->fetch()) { var_dump($arr); } ?> Expected result: ---------------- Count array(2) { ["count"]=> 2 [0]=> 2 } Select array(2) { ["x"]=> string(3) "abc" [0]=> string(3) "abc" } array(2) { ["x"]=> string(3) "def" [0]=> string(3) "def" } Actual result: -------------- Count array(2) { ["count"]=> NULL [0]=> NULL } Select array(2) { ["x"]=> string(3) "abc" [0]=> string(3) "abc" } array(2) { ["x"]=> string(3) "def" [0]=> string(3) "def" }