从MySQL触发器调用PHP脚本 [英] Invoking a PHP script from a MySQL trigger

查看:137
本文介绍了从MySQL触发器调用PHP脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当将记录插入到MySQL数据库表中时,有什么方法可以调用PHP页面/函数?我们无法控制记录插入过程.有没有可以回调PHP脚本的触发机制?

Is there any way how to invoke a PHP page / function when a record is inserted to a MySQL database table? We don't have control over the record insertion procedure. Is there a trigger mechanism which can call a PHP script back?

推荐答案

触发器在MySQL服务器上执行,而不是在PHP服务器上执行(即使它们都在同一台计算机上).

The trigger is executed on the MySQL server, not on the PHP one (even if those are both on the same machine).

所以,我想这不太可能-至少不是简单的.

So, I would say this is not quite possible -- at least not simply.


不过,请考虑此条目从触发器的MySQL常见问题解答中:


Still, considering this entry from the MySQL FAQ on Triggers :

23.5.11:触发器可以通过UDF调用外部应用程序吗?

是的.例如,触发器可以 调用此处可用的sys_exec() UDF: https://github.com/mysqludf/lib_mysqludf_sys#readme

Yes. For example, a trigger could invoke the sys_exec() UDF available here: https://github.com/mysqludf/lib_mysqludf_sys#readme

因此,可能有一种通过UDF函数启动php可执行文件/脚本的方法.并不是那么容易,但是似乎有可能. ;-)

So, there might be a way via an UDF function that would launch the php executable/script. Not that easy, but seems possible. ;-)

这篇关于从MySQL触发器调用PHP脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆