Mysql Auto Update Event

using php and MySql, you still need the date in the database to be updated by itself when the date has expired. that is, the name of the event x on the date 2012-05-12, in 2012-05-13 the date should be changed to 2012-05-19 (week from 2012-05-12)

thanks guys

+3
source share
1 answer

You can use MySQL event planner :

CREATE EVENT update_date ON SCHEDULE EVERY 1 DAY STARTS CURDATE() DO
  UPDATE events_table
  SET    event_date = ADDDATE(event_date, INTERVAL 1 WEEK)
  WHERE  event_date < CURDATE();

To start the event scheduler, you can add this to my.cnf:

[mysqld]
...
event_scheduler = ON

and with superuser privileges, you can set the global variable on the fly:

SET GLOBAL event_scheduler='ON';
+1
source

All Articles