php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56302 pgsql fails with select count(*) from table
Submitted: 2005-02-15 06:13 UTC Modified: 2005-02-15 07:39 UTC
From: jlim at natsoft dot com Assigned:
Status: Closed Package: PDO_pgsql (PECL)
PHP Version: 5_0 CVS-2005-02-15 (dev) OS: WinXP SP2
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.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jlim at natsoft dot com
New email:
PHP Version: OS:

 

 [2005-02-15 06:13 UTC] jlim at natsoft dot com
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"
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-15 07:39 UTC] edink at emini dot dk
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Oct 20 08:01:24 2020 UTC