Jump to content


Photo

MySQL function need onupdate?????


  • Please log in to reply
1 reply to this topic

#1 judd48

judd48
  • Members
  • Pip
  • Newbie
  • 1 posts

Posted 07 January 2006 - 08:45 AM

Hello all,
Im making a site and i need a column in the database that is set to update itself to the curreent time every tie that row is altered ive been looking around and all i could dig up was OnUpdate() and i cant seem to find out how to use this anyone got an idea???

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 07 January 2006 - 06:41 PM

In theory, you the first TIMESTAMP column in table automatically gets updated with the current date/time whenever a new row is inserted/updated without its value being specified explicity. However, in practice, I think it's a terrible idea -- it's much simpler to just include "NOW()" in your INSERT/UPDATE query, and it allows you to have a proper DATETIME column as well. They did make some minor improvements in MySQL 5, but it's still a bad idea. Go the easy route, no fancy columns, easy SQL statements to achieve your goal.

Hope that helps.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users