I have a problem i am getting data from my order table means a user can edit the order and price . But today i think how can i know that particular order is open by any other user or other user is editing on that particular order . Means i want to restrict user to edit that particular order when any one is edit on that ?
Share
You could add a “lock” field to the record that is set, when a user press some “edit” button and released when when he saves. But as already stated, this might not always be the best solution. Don’t forget that you also have to handle abandoned locks etc.
A better solution (imho) would be to check – just before any user saves his changes – if the record has been changed, since it was “loaded” by this user. Either comparing field by field, checking a “last_changed” field, comparing a hash or whatever you prefer. If your check shows that the record has been changed you can prompt the user for the desired action. Like discard his changes, overwrite the previous changed or merge the changes (if possible).