I want to invoke and execute a PHP script from a MySQL procedure. Is this possible?
CREATE PROCEDURE simpleproc (OUT param1 INT)
BEGIN
Call my p
DELIMITER @@
CREATE TRIGGER Test_Trigger
AFTER INSERT ON MyTable
FOR EACH ROW
BEGIN
DECLARE cmd CHAR(255);
DECLARE result int(10);
SET cmd=CONCAT('/usr/bin/php ', '/home/test/beta/demo.php');
SET result = sys_exec(cmd);
END;
@@
DELIMITER ;
source
It's possible, See the MySQL FAQ for an explanation of how
Can triggers call an external application through a UDF?
But it's likely to be bad design on your part if you have to resort to this
For solve your problem you can create table for tasks. From stored procedure you can put to this table any string for task. On server you can run PHP script by crontab. Script will check this table and make some operation.