mysql trigger with php script

别说谁变了你拦得住时间么 提交于 2019-12-20 07:12:58

问题


I have the next mysql trigger:

DELIMITER @@

CREATE TRIGGER Test_Insert
BEFORE INSERT ON sat_clientLocation
FOR EACH ROW 
BEGIN
DECLARE cmd CHAR(255);
DECLARE result int(10);
SET cmd=CONCAT('/usr/bin/php ', '/var/www/html/poi/insertTest.php' , NEW.idLocation);
SET result = sys_exec(cmd);

END;
@@
DELIMITER ; 

It's possible to use NEW.idLocation in my php file? I try some methods, but don't work.


回答1:


According to that solution:

SET cmd=CONCAT('/usr/bin/php ', 
               '/var/www/html/poi/insertTest.php?location=' ,
               NEW.idLocation);

That will be passed to your script as $_GET[] variable:

<?php
echo $_GET['location'];
?>


来源:https://stackoverflow.com/questions/49277837/mysql-trigger-with-php-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!