Prevent user from editing the same record

纵然是瞬间 提交于 2019-12-02 16:16:27

问题


I'm developing a Multiple user application on same network usign MySQL & Java. What I'm looking for is: User A: Modifying Record 100 User B: Try to view or modify same record 100.

I want the application to return error message for User B, that record already editing by another user.

How can i do this?


回答1:


Include an edit_timestamp in the tables of your database you want to prevent from multiple users updating, which you'll update every time anyone edit the row.

In your forms, include a hidden field edit_timestamp with the value stored in the row you're editing.

When you receive a edit form, check if the edit_timestamp of the row that you're editing hasn't changed. If it has changed, someone has edited the row and throw an error to the user. If it hasn't changed, update the row and the edit_timestamp field



来源:https://stackoverflow.com/questions/16562058/prevent-user-from-editing-the-same-record

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!