1

I am currently creating my first event in MySQL:

CREATE EVENT check_for_uploads
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 MINUTE
ON COMPLETION PRESERVE
DO
   // I would like to open a .php file here

However I cannot find information on if its possible to open a file from there. I think I have seen it in some tutorial.

Thank you very much!

2

You cannot or should not manipulate files within a store procedure (which is basically the same as an event, but with a schedule) due to scope and security reasons.

MySQL events and stored procedures are supposed to only modify or read data using SQL, and not go outside of the database server responsibilities. If MySQL server could read or execute arbitrary files, that would be considered a vulnerability and would be patched (with the exception of LOAD DATA or very few other very specific commands). While certain plugins allow accessing or executing arbitrary data, that is considered an exception, and not the normal way of using MySQL.

Normally PHP applications access MySQL as a resource, not the other way round. You may want to setup a UNIX cron or Window task scheduler at your OS to do what you are trying to do (executing PHP code) instead, rather than using the database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.