Page 1 of 1

Timestamp columns - How to NOT update!

Posted: Fri Feb 11, 2005 10:07 am
by TheOracle
Hi All,

I have a timestamp column in my database which is initially populated when adding a record through the web page.

However, once this is populated I do not want it to change unless I specifically specify that it should. Yesterday I was doing some work through phpMyAdmin and I happened to do some updates on this table and found today that it had updated the timestamp column.

How can I avoid this, change it.

The web page basically records work carried out on a server, so creating an audit log. Obvioulsy the data and time are essential to this. There will be no updates on the table in the long-term, but until we have settled it in I don't want the timestamp changing.

Any Ideas?

Thanks

Posted: Fri Feb 11, 2005 10:09 am
by d3ad1ysp0rk
make it an int field, then use PHP's time() function to populate it on update.

Posted: Fri Feb 11, 2005 10:17 am
by timvw
use datetime instead of timestamp..... and next time read your dbms documentation...... (there are some differences for timestamp in mysql < 4.1 and later)

Posted: Fri Feb 11, 2005 10:24 am
by TheOracle
Cheers guys.

I have tested both, but I think timvw wins.

Once again many thanks