I have two TIMESTAMP fields in my user table that I want to update with the current timestamp, one when the row/account is created and the other every time a user logs in.
I am having trouble updating using:
UPDATE user SET last_login = NOW() WHERE id = 1
and
UPDATE user SET created = NOW() WHERE id = 1
The queries are not having any affect. I’m thinking this is an issue with the table setup and have tried many different options.
1 is the id of the user and is hardcoded for this example. I have also tried hardcoding the value in my code and checking to make sure my code reaches the query. Still no dice.
Any ideas what I should set my table fields to?
Be aware that TIMESTAMP columns can be set to update automatically, thus overriding your manual changes:
http://dev.mysql.com/doc/refman/5.5/en/timestamp.html
Make sure you haven’t enabled any of these properties (or switch to another data type that does not have such features).