multi-user application record locking – best method? Ask

Questionsmulti-user application record locking – best method? Ask
Christian asked 6 years ago


I am building a web-app that allows several users to perform read and write-operations on the same table. What is the smartest way of preventing that a record in the table is simultaneously edited by different users (ie. changes from user A get overwritten by user B without any of users noticing the conflicting behaviour)?


4 Answers
Abu Ghufran answered 6 years ago


I have not tested this scenario before.
I'll let you know after some research on jqgrid available events.

Abu Ghufran answered 6 years ago

If you can limit with dialog editing, you can use following events of edit dialogs.
afterShowForm and onClose. You can make a custom ajax call in JS function to set lock field of edited row id.

Plus, you need to set "rowactions"=>false to disable inline editing.

Demo usage here:

pcattani answered 9 months ago


I am writing an application which will be used by multiple users and am considering how to use database locks.  Can you clarify the nature of this function in your above example?:



Is lock_rowid a custom function which needs to be written?  This looks like it’s a lock on the front-end with the GUI rather than at the database level.  Is that correct?



– pcatt

Abu Ghufran Staff answered 9 months ago

Yes, that’s correct. It’s Client side locking solution. For server side, you need to introduce a field of locked with that item.


Above code is a jQuery solution of a JS global variable which is available everywhere in JS code. So we set it when dialog is opened and unset when it’s closed.

Demo does not show how to apply this limitation when opening edit dialog.

I’ve updated demo to have this as well. (line 30-55)

You need to put custom ajax calls to check on server if that rowid is locked or not.

Let me know in case of further queries.

Abu Ghufran - Dev Team
Grid 4 PHP Framework
Your Answer

14 + 3 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.

How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?