PHP数据库值变化监听器,有没有更好的办法? [英] PHP Database Value Change Listener, is there a better way?

查看:1168
本文介绍了PHP数据库值变化监听器,有没有更好的办法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本公司经营与销售。我们收到的订单,我们的PHP应用程序允许我们的客户服务代表来处理这些订单。

Our company deals with sales. We receive orders and our PHP application allows our CSRs to process these orders.

有在数据库中,是不断取决于哪个顺序正在由特定的CSR处理改变的记录 - 存在用于每CSR这些领域中的一个。

There is a record in the database that is constantly changing depending on which order is currently being processed by a specific CSR - there is one of these fields for every CSR.

目前,数据库中的每个第二使用xmlhhtp请求一个完全独立的页面轮询并接收响应。如果响应不为空(仅当值已更改数据库),它执行的操作。

Currently, a completely separate page polls the database every second using an xmlhhtp request and receives the response. If the response is not blank (only when the value has changed on the database) it performs an action.

正如你可以想像,这相当于每秒一个DATABSE查询以及HTTP请求每一秒。

As you can imagine, this amounts to one databse query per second as well as a http request every second.

我的问题是,有没有更好的方式来做到这一点?可能使用套接字的监听器?当已经执行了一些会ping我的脚本的变化而迫使我查询数据库和/或发送HTTP请求。​​

My question is, is there a better way to do this? Possibly a listener using sockets? Something that would ping my script when a change has been performed without forcing me to poll the database and/or send an http request.

在此先感谢

推荐答案

首先,1查询/秒,1请求/秒还真是不多。特别是因为当你获得更多的客户服务代表或销售该号码不会改变。如果你执行1查询/订单/秒或东西,你可能会担心,但因为它的立场,如果它工作得很好,我可能不会改变。这可能是值得运行的查询某些衡量标准,以确保其运行速度很快,在选择索引列等。大多数数据库提供了一种方法来检查如何执行查询时,就像在MySQL中EXPLAIN语法。

First off, 1 query/second, and 1 request/second really isn't much. Especially since this number wont change as you get more CSRs or sales. If you were executing 1 query/order/second or something you might have to worry, but as it stands, if it works well I probably wouldn't change it. It may be worth running some metrics on the query to ensure that it runs quickly, selecting on an indexed column and the like. Most databases offer a way to check how a query is executing, like the EXPLAIN syntax in MySQL.

这是说,有几个选项。

  • 使用数据库触发器要么进行必要的更新,当一个编辑而成,或调用外部脚本。 MySQL的一些参考资料: http://dev.mysql.com /doc/refman/5.0/en/create-trigger.html
  • 有什么软件的客户服务代表使用直接调用第二个脚本,使更新时。
  • 在降低轮询频率。

这篇关于PHP数据库值变化监听器,有没有更好的办法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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