#39971 [Asn->Csd]: pg_insert / pg_update do not allow now() to be used for timestamp fields

From: Date: Fri, 29 Dec 2006 00:35:44 +0000
Subject: #39971 [Asn->Csd]: pg_insert / pg_update do not allow now() to be used for timestamp fields
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-106982@lists.php.net to get a copy of this message
 ID:               39971
 Updated by:       iliaa@php.net
 Reported By:      epotocko at gmail dot com
-Status:           Assigned
+Status:           Closed
 Bug Type:         PostgreSQL related
 Operating System: Windows XP
 PHP Version:      5.2.0
 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:
------------------------------------------------------------------------

[2006-12-28 15:32:35] tony2001@php.net

The error comes from php_pgsql_convert(), see ext/pgsql/pgsql.c:4975.

------------------------------------------------------------------------

[2006-12-28 15:14:29] iliaa@php.net

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

The error comes from PostgreSQL, PHP simply relays it to you.

------------------------------------------------------------------------

[2006-12-28 02:06:09] 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) 


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=39971&edit=1


Thread (4 messages)

« previous php.bugs (#106982) next »