#42783 [Asn->Csd]: pg_insert() does not accept an empty list for insertion.

From: Date: Wed, 03 Oct 2007 23:32:05 +0000
Subject: #42783 [Asn->Csd]: pg_insert() does not accept an empty list for insertion.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-118165@lists.php.net to get a copy of this message
ID: 42783 Updated by: iliaa@php.net Reported By: maciej-php at killer-robot dot net -Status: Assigned +Status: Closed Bug Type: PostgreSQL related Operating System: Debian Linux PHP Version: 5.2.4 Assigned To: iliaa New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2007-10-03 13:33:34] tony2001@php.net Ilia, could you take a look at it plz? ------------------------------------------------------------------------ [2007-09-27 19:38:20] 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) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42783&edit=1

« previous php.bugs (#118165) next »