php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18713 pg_exec does not return objectid from insert
Submitted: 2002-08-02 17:01 UTC Modified: 2002-08-02 19:03 UTC
From: jam at newimage dot com Assigned:
Status: Not a bug Package: PostgreSQL related
PHP Version: 4.1.2 OS: redhat 7.3
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jam at newimage dot com
New email:
PHP Version: OS:

 

 [2002-08-02 17:01 UTC] jam at newimage dot com
I've found what I believe is a bug in the php postgresql module.

Consider this code:
1 $db = pg_connect("dbname=phpserve user=apache");
2
3 $sql = "insert into orders(userid, datestamp, completed) 4 values ('0', 'now()', 'f')";
5 $res =  pg_exec($sql) or die("invalid query");
6
7 print_r($res);
8 print "<br />";
9 print count($res);
10 $foo = pg_fetch_row($res, 0);
11 print_r($foo);

the insert runs fine. the output is "Resource id #2" (which is good), then a 1 (for the count, which is also good) and then an error for the pg_fetch_row() call (error is "PHP Warning:  Unable to jump to row 0 on PostgreSQL result index 2 in /var/www/html/phpserve/test.php on line 11") which is where the problem lies. the result from an insert should be the objectid of the record. I'm willing to entertain the possibility that I've done something wrong with my code, and that this isn't a bug in php.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-02 19:03 UTC] sniper@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 18:01:29 2024 UTC