|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-10-03 13:33 UTC] tony2001@php.net
[2007-10-03 23:32 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 10:00:01 2025 UTC |
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)