RE: [PHP] timestamp triggered only on update?

From: Date: Fri, 26 Jul 2002 01:31:56 +0000
Subject: RE: [PHP] timestamp triggered only on update?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-109644@lists.php.net to get a copy of this message
> Im used to for instance 2 columns in each table indicating when it was > created and when it was last updated: > > Changed_date > Registered_date > > In mysql it seems it is only possible to define a column as a timestamp, > and > this will trigger both on insert and delete. Is it possible to define > changed_date to trigger only on update in mysql or do i have do give the > correct timestamp "manually" from php? I don't really understand your question. MySQL will update the first timestamp in a table on an INSERT or UPDATE to the current time. Other timestamp columns will remain unchanged. It sounds like you could put changed_date first, so it's always updated with each UPDATE, and put registered_date second so that it's only set when the row is first INSERTed. You can also use a DATETIME column, which is exactly the same; it's just not updated automagically. ---John Holmes...

« previous php.general (#109644) next »