Ask a Question related to PHP Bugs, Design and Development.
-
iliaa@php.net #1
#37037 [Ana->WFx]: pgsql: Can't access result returned from an INSERT
ID: 37037
Updated by: [email]iliaa@php.net[/email]
Reported By: shadda at gmail dot com
-Status: Analyzed
+Status: Wont fix
Bug Type: PDO related
Operating System: Debian 3.1
PHP Version: 5.1.3RC2
Previous Comments:
------------------------------------------------------------------------
[2006-05-01 01:08:20] [email]wez@php.net[/email]
The issue related to native prepared statements not describing that
magical result set.
Workaround:
$stmt = $db->prepare("insert into test_table default values", array(
PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => true));
$stmt->execute();
print_r($stmt->fetchAll());
------------------------------------------------------------------------
[2006-04-11 10:36:53] shadda at gmail dot com
Just a quick note -- in the above insert statement, the table should be
'test_table'
------------------------------------------------------------------------
[2006-04-11 10:30:53] shadda at gmail dot com
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;
postgres@Xanadu:/$ 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 this bug report at [url]http://bugs.php.net/?id=37037&edit=1[/url]
iliaa@php.net Guest
-
interogate result returned in DeltaPacket
I need to determine what my database assigned to the key of a record that was just inserted. I can see in NetConnection Debugger, in the... -
how to access the array returned from xmlsearch
I am having an xmlsearch function, from which i am getting the attributes of the nodes, which satisfy Only one element is returned that is ... -
Deleting specific rows from a returned query result
I execute a <cfquery> statement block, and that works fine. However, I need to manipulate the return query rows by deleting the ones that do not... -
How to use returned result sets from a client app?
Hi there, In the IBM sample file (see /opt/IBM/db2/V8.1/samples/cpp), spserver.sqC, it implemented a routine called two_result_sets(...). In... -
#19775 [NoF->Opn]: PHP crashes when trying to access 2d int matrix returned from java
ID: 19775 User updated by: waazup at hotmail dot com Reported By: waazup at hotmail dot com -Status: No Feedback...



Reply With Quote

