php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42783 pg_insert() does not accept an empty list for insertion.
Submitted: 2007-09-27 19:38 UTC Modified: 2007-10-03 23:32 UTC
From: maciej-php at killer-robot dot net Assigned: iliaa (profile)
Status: Closed Package: PostgreSQL related
PHP Version: 5.2.4 OS: Debian Linux
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: maciej-php at killer-robot dot net
New email:
PHP Version: OS:

 

 [2007-09-27 19:38 UTC] maciej-php at killer-robot dot net
Description:
------------
pg_insert() does not accept empty lists of values. Empty lists of values can be useful for tables with defaults set on columns. Postgres provides a construct for inserting an empty list: "INSERT INTO foo DEFAULT VALUES".

Reproduce code:
---------------
pg_query($conn, 'CREATE TABLE foo (id SERIAL PRIMARY KEY, time TIMESTAMP NOT NULL DEFAULT now())');
var_dump( pg_insert($conn, 'foo', array('time' => '2007-08-08 1:30:00'), PGSQL_DML_STRING));
var_dump( pg_insert($conn, 'foo', array(), PGSQL_DML_STRING));


Expected result:
----------------
string(53) "INSERT INTO foo (time) VALUES ('2007-08-08 1:30:00');"
string(30) "INSERT INTO foo DEFAULT VALUES"

Actual result:
--------------
string(53) "INSERT INTO foo (time) VALUES ('2007-08-08 1:30:00');"
bool(false)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-03 13:33 UTC] tony2001@php.net
Ilia, could you take a look at it plz?
 [2007-10-03 23:32 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 09:01:31 2024 UTC