MYSQL trigger that externally runs a PHP script

I am currently trying to use mysql trigger to run php script. When launched, the script retrieves data from a specific website and places it in another table. I tested the script and it works when I run it with php5. I also set lib_mysqludf_sys correctly and moved the corresponding folders to the plugin folder for mysql. When I created the trigger, I did not get any errors. It just does not run my PHP script. Where am I wrong and how can I fix it?

DELIMITER $$
CREATE TRIGGER getFriends
    -> AFTER INSERT ON tbluser
    -> FOR EACH ROW    
    -> BEGIN
    ->   DECLARE RESULT INT;
    ->   SET RESULT = sys_exec('php5 /var/www/html/getFriends.php');
    ->END$$;
DELIMITER ;
+4
source share
1 answer

Confirm that you are using the right folder:

SHOW VARIABLES LIKE 'plugin_dir';

Restore function:

DROP FUNCTION IF EXISTS sys_exec;
CREATE FUNCTION sys_exec RETURNS int SONAME 'lib_mysqludf_sys.so';

, :

SET RESULT = sys_exec('/usr/bin/php5 /var/www/html/getFriends.php');

, MySQL , script , .

+1

Source: https://habr.com/ru/post/1617535/


All Articles