navicat ror mysql查询事件,如何在MySQL查询为真后触发触发的事件?

How does one create a PHP script that checks the MySQL row consistently and if a set query is matched, it starts an event, such as sending an email?

For example, on query match Fire start email:

To: me@me.com

From: php@trigger.com

Subject: Set query met, auto email complete.

It would be around MySQL5. I'm stuck on this. Am I best to do it in Perl or similar?

Perhaps it could also email various users? (This isn't the hard bit. :P)

解决方案

Using cron or similar scheduler involves polling, which works but is brute force and ignorance. I can't recommend it: there's a time delay between when the row changes and when cron executes the checking program; repeated checking is a waste of resources.

The elegant solution is database trigger, see Using Triggers and Can triggers call an external application through a UDF?. You will get an event whenever your table row is on fire or something, and your email sending program is called immediately.

If you want to use Perl, Email::Simple/Email::Sender is nifty.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值