php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56428 nextval() always returns NULL
Submitted: 2005-06-25 14:02 UTC Modified: 2005-06-29 09:57 UTC
From: bjori at jeshus dot com Assigned:
Status: Closed Package: PDO_PGSQL (PECL)
PHP Version: 5.0.3 OS: FreeBSD 5.3-RELEASE
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bjori at jeshus dot com
New email:
PHP Version: OS:

 

 [2005-06-25 14:02 UTC] bjori at jeshus dot com
Description:
------------
(running PHP5.0.4, not .3)
PDO 0.3
PDO_PGSQL 0.2
select nextval() *always* returns NULL

Reproduce code:
---------------
<?php
    $PDO = new PDO(...);
    $PDO->setAttribute(PDO_ATTR_CASE, PDO_CASE_UPPER);
    
    $sql = "CREATE TABLE foo(id serial not null primary key)";
    $PDO->exec($sql);
    
    $sql = "INSERT INTO foo VALUES(1);";
    $PDO->exec($sql);
    
    $sql = "SELECT nextval('foo_id_seq')";
    $PDOStatement = $PDO->prepare($sql);
    $PDOStatement->execute();
    
    $PDOStatement->bindColumn("NEXTVAL", $id);
    $row = $PDOStatement->fetchAll();
    
    var_dump($id, $row, $PDO->errorInfo(), $PDOStatement->errorInfo());
    
    $sql = "DROP TABLE foo";
    $PDO->exec($sql);
?>


Expected result:
----------------
2
array(1) {
  [0]=>
  array(2) {
    ["NEXTVAL"]=>
    2
    [0]=>
    2
  }
}
array(1) {
  [0]=>
  string(5) "00000"
}
array(1) {
  [0]=>
  string(5) "00000"
}


Actual result:
--------------
NULL
array(1) {
  [0]=>
  array(2) {
    ["NEXTVAL"]=>
    NULL
    [0]=>
    NULL
  }
}
array(1) {
  [0]=>
  string(5) "00000"
}
array(1) {
  [0]=>
  string(5) "00000"
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-28 18:36 UTC] edink at emini dot dk
Could you please try the latest CVS version. There I get 
the correct result, 1 (and not 2).

PDO is bundled in the latest 5.1 snapshots.
 [2005-06-29 09:57 UTC] bjori at jeshus dot com
Works like a charm in CVS. Thanks
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 00:01:30 2024 UTC