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

查看:34
本文介绍了从 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 常见问题:

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天全站免登陆