客户端-服务器方法中的持久事务
在我的应用程序(客户端-服务器)中,我需要编辑一些行(来自数据库),只要它们被编辑,就不需要任何人能够编辑。这当然是通过交易来完成的。问题在于,在客户端环境中,事务在服务器端进行管理,因此编辑行的客户端无法直接访问事务。 (我在这种情况下使用 PHP,但认为其他技术也采用了相同的方法)。因此,我需要保持事务打开(以保持行锁定以进行编辑),直到客户端完成编辑。 在 PHP 中,持久连接没有帮助,因为它们可能会被与上述客户端位于同一主机的其他客户端断开。您对我的场景有什么想法吗?
谢谢。
In my application (client-server) I need to edit some rows (from a database), and as long as they are edited it needs nobody to be able to edit also. This is done by transactions of course. The problem is that in a client-side environment the transactions is managed on the server side, so the client that edits the rows can't access the transaction directly. (I'm working with PHP in that situation but think that the same approach is adopted in other technologies also). So I need to keep transaction opened (for keeping rows locked for editing) until the client finishes the edit.
In PHP, persistent connection won't help because they can be broken from other clients located in the same host with the aforesaid client. Do you have any ideeas for my scenario?
thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通常,此类情况是通过直接在对象或对象的父对象上设置的业务锁来处理的。
添加一个列,例如“inedition”,当用户声明编辑时将其设置为 true,并在用户验证/取消其编辑时设置为 false。
请注意,在解锁行之前,某些用户事务可能会丢失,因此您可能需要:
编辑:
当您不想依赖数据库特定功能(例如 Oracle“选择更新”)时,可以使用这种解决方案。在 Java 中,EJB 有状态 bean 可以保留对从 UI 到数据库的事务的引用。可能有使用 PHP for Oracle 或有关事务的其他数据库特定功能的解决方案,具体取决于数据库。
Usually such cases are handled through business locks that you set directly on the objects, or on the parent of the objects.
Add a column such "inedition" that you set to true when user claims for edit, and set to false when user validate/cancel its edit.
Be aware that some users transactions are likely to be lost before that you unlock the row, so you'll probably require:
Edit:
This kind of solution is used whenever you do not want to rely on database specific feature, such Oracle "Select for update". In Java an EJB statefull bean can keep a reference to the transaction from UI to database. There might be solutions using PHP for Oracle or other database specific feature regarding transactions, depending on databases.