From: shadda at gmail dot com
Operating system: Debian 3.1
PHP version: 5.1.3RC2
PHP Bug Type: PDO related
Bug description: Can't access result returned from an INSERT
Description:
------------
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
DO ALSO
SELECT NEW.id;
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 new.id;
[EMAIL PROTECTED]:/$ php -r '
$db = new
PDO("pgsql:host=localhost;user=xoom;password=1914;dbname=general");
$q = $db->query("insert into foo default values");
var_dump($q->fetch());
'
Expected result:
----------------
array(2) {
[0]=>
string(2) "10"
["id"]=>
string(2) "10"
}
Actual result:
--------------
array(0) {
}
--
Edit bug report at http://bugs.php.net/?id=37037&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=37037&r=trysnapshot44
Try a CVS snapshot (PHP 5.1):
http://bugs.php.net/fix.php?id=37037&r=trysnapshot51
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=37037&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=37037&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=37037&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=37037&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=37037&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=37037&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=37037&r=support
Expected behavior: http://bugs.php.net/fix.php?id=37037&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=37037&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=37037&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=37037&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37037&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=37037&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=37037&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=37037&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=37037&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=37037&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=37037&r=mysqlcfg