Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7670671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:52:32+00:00 2026-05-31T15:52:32+00:00

I have a PHP/jQuery/AJAX/MySQL app built for managing databases. I want to implement the

  • 0

I have a PHP/jQuery/AJAX/MySQL app built for managing databases. I want to implement the ability to prevent multiple users from editing the same database row at the same time.

  1. What is this called?
  2. Do I use a token system and who ever has the token can edit it until they release the token?
  3. Do I use a “last edit date/time” to compare you loading the HTML form with the time in the database and if the database is the most resent edit then it warns you?
  4. Do I lock the row using database functions?

I’m just not sure which is the best. Assuming between 10 – 15 concurrent users

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:52:33+00:00Added an answer on May 31, 2026 at 3:52 pm

    There are two general approaches– optimistic and pessimistic locking.

    Optimistic locking is generally much easier to implement in a web-based environment because it is fundamentally stateless. It scales much better as well. The downside is that it assumes that your users generally won’t be trying to edit the same set of rows at the same time. For most applications, that’s a very reasonable assumption but you’d have to verify that your application isn’t one of the outliers where users would regularly be stepping on each other’s toes. In optimistic locking, you would have some sort of last_modified_timestamp column that you would SELECT when a user fetched the data and then use in the WHERE clause when you go to update the date, i.e.

    UPDATE table_name
       SET col1 = <<new value>>,
           col2 = <<new values>>,
           last_modified_timestamp = <<new timestamp>>
     WHERE primary_key = <<key column>>
       AND last_modified_timestamp = <<last modified timestamp you originally queried>>
    

    If that updates 1 row, you know you were successful. Otherwise, if it updates 0 rows, you know that someone else has modified the data in the interim and you can take some action (generally showing the user the new data and asking them if they want to overwrite but you can adopt other conflict resolution approaches).

    Pessimistic locking is more challenging to implement particularly in a web-based application particularly when users can close their browser without logging out or where users may start editing some data and go to lunch before hitting Submit. It makes it harder to scale and generally makes the application more difficult to administer. It’s really only worth considering if users will regularly try to update the same rows or if updating a row takes a large amount of time for a user so it’s worth letting them know up front that someone else has locked the row.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php / mysql / jquery web app that makes 13 ajax
I have implement the exact same concept for my project- http://blog.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/ My question is,
i want to import .txt file values into mysql using php and jquery/Ajax without
I have a jquery-ajax function that sends data to a php script and the
I have an application that posts data to a php script through jquery's ajax
I have a form what jQuery sents for me using Ajax to php. For
I have written jQuery code, in files Main.html and ajax.php . The ajax.php file
I have some jQuery code. I have called an Ajax function file, file.php, that
I have this jQuery script var dataString = class_id=+class_id; $.ajax({ type: POST, url: page.php,
I am having problems with jQuery Ajax and PHP I have my php file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.