Page 1 of 1
Time and time again.
Posted: Wed Nov 13, 2002 11:27 pm
by serambin
Is there a simple way to activate a timestamp in MySQL without passing a variable from the php script? What I want to do is have a timestamp field in the database which (NOW)'s every time a new record is added.
Thanks,
Stan

Posted: Thu Nov 14, 2002 2:07 am
by twigletmac
When you do your update just reset the field along with anything else you're changing:
Code: Select all
UPDATE table SET value='something', lastupdate=NOW() WHERE ID=whatever
Mac
Re: Time and time again.
Posted: Thu Nov 14, 2002 8:52 am
by mester
serambin wrote:Is there a simple way to activate a timestamp in MySQL without passing a variable from the php script? What I want to do is have a timestamp field in the database which (NOW)'s every time a new record is added.
Thanks,
Stan

Create a column TIMESTAMP. It will be updated every time you do some modification to the record. Read the manual!

Posted: Thu Nov 14, 2002 9:01 am
by twigletmac
Manual Labor
Posted: Thu Nov 14, 2002 10:45 am
by serambin
Sorry, I did read the manual,
I was using a Timestamp(14) without being specified explicitly in an INSERT or LOAD DATA INFILE statement. However, when setting up the field in MySQLAdmin, the column was set to null even after I 'appeared' to have sucessfully changed it to non null (even deleted and recreated). That's why I was looking for another solution. I finally am using datetime and setting it in the code explicitly.
Thanks for the kind replies,
Stan