0

I'm new to php. I want to execute mysql query periodically (say every 5 seconds) using script. Query can be anything (as for now such as getting all data one by one from databse or inserting data to database). How can I do this? I've been through some examples but as I'm new to php, I'm not getting.

thumber nirmal
  • 1,639
  • 3
  • 16
  • 27

2 Answers2

1

you can do this using event or cron job created on server

Event

using event

DELIMITER $$

ALTER EVENT `ev_myevent` ON SCHEDULE EVERY 5 SECOND STARTS '2013-10-23 11:00:00' ON COMPLETION PRESERVE ENABLE DO BEGIN
// your code here
END$$

DELIMITER ;

using cronjob

check this link
1 Cronjob execute PHP script

2 Managing Cron Jobs with PHP

Community
  • 1
  • 1
Pragnesh Chauhan
  • 8,363
  • 9
  • 42
  • 53
0

If you want to update content in your site every 5 seconds and update database then you do it by ajax calling. Other then if you want to update database periodically then use cron.

SKG
  • 510
  • 4
  • 20