how to increase a field value of mysql table every some minutes automatically
I have a field in mysql table that I want increase开发者_C百科 this field value every about 5 min (298 seconds) ,
how we could increase this field value?
thanks
If you are using MySql version 5.1.6 or above, you can use the built in event scheduler:
CREATE EVENT e_update ON SCHEDULE EVERY 298 SECOND DO
UPDATE tableName SET Col = Col + 1;
Or
CREATE EVENT e_update ON SCHEDULE EVERY 5 MINUTE DO
UPDATE tableName SET Col = Col + 1;
You could make a php script that updates your database field however you like, then create a cron job that executes this script every five minutes.
Replace PHP with your scripting language of choice.
One way to do this is to have a php script on your server, called by cron every 5 mins.
*/5 * * * * /home/whatever/updateField.php
精彩评论