pg_insert() does not accept an empty list for insertion.
| 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 | ||
[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 commits
[2007-10-03 23:32 UTC] iliaa@php.net