Harinder
Harinder

Reputation: 1257

How can i run script as soon as mysql database is update (cronjob)

How can i run a script as soon as mysql database is updated. I have a script in test.php, and i want to run every time, i get sms into (or entry u can say) my database example if massage is received at 10:20:56 sec script should run at 10:20:57 sec.. any thing will do like cronjob java php .any script

Upvotes: 1

Views: 3085

Answers (3)

dbf
dbf

Reputation: 6499

If value is inserted via your code you can just add call of script just after insert. If it is inserted in code, that is not managed by you, than you should poll your database every N seconds and check for new records and call your php script.

Upvotes: 0

Alex Stybaev
Alex Stybaev

Reputation: 4693

You could try to create ON UPDATE trigger and try to invoke PHP script. Here is more about that.

Upvotes: 1

stUrb
stUrb

Reputation: 6832

Take a look at triggers in conjunction with your mysql database. With that you can run a sql-query on every update, insert or modification.

Simplified Syntax:

CREATE
    TRIGGER trigger_name trigger_time trigger_event
    ON tbl_name FOR EACH ROW trigger_body

Upvotes: 0

Related Questions