PHP :: Bug #39971 :: pg_insert
| Bug #39971 | pg_insert / pg_update do not allow now() to be used for timestamp fields | ||||
|---|---|---|---|---|---|
| Submitted: | 2006-12-28 02:06 UTC | Modified: | 2006-12-29 00:35 UTC | ||
| From: | epotocko at gmail dot com | Assigned: | iliaa (profile) | ||
| Status: | Closed | Package: | PostgreSQL related | ||
| PHP Version: | 5.2.0 | OS: | Windows XP | ||
| Private report: | No | CVE-ID: | None | ||
[2006-12-28 02:06 UTC] epotocko at gmail dot com
Description:
------------
The pg_insert and pg_update functions will not accept now() as a valid value for timestamp fields.
Reproduce code:
---------------
// Assumes the following table exists:
/*
CREATE TABLE timestamp_test
(
id serial NOT NULL,
mytime timestamp NOT NULL,
CONSTRAINT timestamp_test_pkey PRIMARY KEY (id)
)
WITHOUT OIDS;
*/
$dbConn = pg_connect();
$values = array('mytime' => 'now()');
pg_insert($dbConn, 'timestamp_test', $values);
$ids = array('id' => 1);
$fields = array('mytime' => 'now()');
pg_update($dbConn, 'timestamp_test', $fields, $ids);
Expected result:
----------------
Both the insert and the update should succeed.
Actual result:
--------------
Error Log:
PHP Notice: pg_insert() [<a href='function.pg-insert'>function.pg-insert</a>]: 'now()' does not match with '^([0-9]{4}[/-][0-9]{1,2}[/-][0-9]{1,2})([ \t]+(([0-9]{1,2}:[0-9]{1,2}){1}(:[0-9]{1,2}){0,1}(\.[0-9]+){0,1}([ \t]*([+-][0-9]{1,2}(:[0-9]{1,2}){0,1}|[a-zA-Z]{1,5})){0,1})){0,1}$'
PHP Notice: pg_insert() [<a href='function.pg-insert'>function.pg-insert</a>]: Expects NULL or string for PostgreSQL timestamp field (mytime)
PHP Notice: pg_update() [<a href='function.pg-update'>function.pg-update</a>]: 'now()' does not match with '^([0-9]{4}[/-][0-9]{1,2}[/-][0-9]{1,2})([ \t]+(([0-9]{1,2}:[0-9]{1,2}){1}(:[0-9]{1,2}){0,1}(\.[0-9]+){0,1}([ \t]*([+-][0-9]{1,2}(:[0-9]{1,2}){0,1}|[a-zA-Z]{1,5})){0,1})){0,1}$'
PHP Notice: pg_update() [<a href='function.pg-update'>function.pg-update</a>]: Expects NULL or string for PostgreSQL timestamp field (mytime)
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2006-12-28 15:14 UTC] iliaa@php.net
[2006-12-28 15:32 UTC] tony2001@php.net
[2006-12-29 00:35 UTC] iliaa@php.net