Timestamp columns - How to NOT update!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
TheOracle
Forum Commoner
Posts: 64
Joined: Mon Nov 22, 2004 4:56 am
Location: Bedford, UK

Timestamp columns - How to NOT update!

Post 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
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

make it an int field, then use PHP's time() function to populate it on update.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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)
TheOracle
Forum Commoner
Posts: 64
Joined: Mon Nov 22, 2004 4:56 am
Location: Bedford, UK

Post by TheOracle »

Cheers guys.

I have tested both, but I think timvw wins.

Once again many thanks
Post Reply