|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37037 pgsql: Can't access result returned from an INSERT
Submitted: 2006-04-11 10:30 UTC Modified: 2006-12-30 02:34 UTC
From: shadda at gmail dot com Assigned:
Status: Wont fix Package: PDO related
PHP Version: 5.1.3RC2 OS: Debian 3.1
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:
Bug Type:
From: shadda at gmail dot com
New email:
PHP Version: OS:


 [2006-04-11 10:30 UTC] shadda at gmail dot com
I'm using PostgreSQL 8.1.2, on Debian Sid. In my database, I have a table with a RULE on inserts...

CREATE RULE test_rule AS 
   ON INSERT TO test_table

When a new row is inserted to this table, it returns the ID (currval) of the new row. This works from PSQL, DBI (perl), and JDBC, aswell as the standard Pgsql extension in PHP.

From PDO, however, when calling PDOStatement::Fetch() after an insert, only an empty array is returned, and not the resultset I was expecting.

Reproduce code:
create table test_table ( id serial primary key );
create rule test_rule as on insert to test_table do also select;

postgres@Xanadu:/$ php -r '
$db = new PDO("pgsql:host=localhost;user=xoom;password=1914;dbname=general");
$q = $db->query("insert into foo default values");

Expected result:
array(2) {
  string(2) "10"
  string(2) "10"

Actual result:
array(0) {


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-11 10:36 UTC] shadda at gmail dot com
Just a quick note -- in the above insert statement, the table should be 'test_table'
 [2006-05-01 01:08 UTC]
The issue related to native prepared statements not describing that magical result set.


$stmt = $db->prepare("insert into test_table default values", array(

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 19 08:01:31 2024 UTC