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

  • Home
  • SEARCH
  • 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 6835403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:13:41+00:00 2026-05-26T23:13:41+00:00

How to implement pessimistic locking in a php/mysql web application? web-user opens a page

  • 0

How to implement pessimistic locking in a php/mysql web application?

  1. web-user opens a page to edit one dataset (row)
  2. web-user clicks on the button “lock”, so other users are able to read but not to write this dataset
  3. web-user makes some modifications (takes maybe 1 to 30 minutes)
  4. web-user clicks “save” or “cancel” and the “lock” is removed

Are there standard methods in php/mysql for this scenario? What happens if the web-user never clicks on “save”/”cancel” but closes the internet-exploror?

  • 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-26T23:13:42+00:00Added an answer on May 26, 2026 at 11:13 pm

    Traditionally this is done with a boolean locked column on the record in the database that is flagged appropriately.

    It is a function of this sort of locking that the lock has to be released, and circumstances may prevent this happening naturally (system crashes, user stupidity, dropped network packets, etc etc etc). This is why you would need to provide some manual unlock method and/or impose a time limit (maybe with a cron job?) on how long a record can be locked for. You could implement some kind of AJAX poll to keep the record locked if the browser is still open? At any rate, you would probably be best to verify the data in the record is the same as it was when the lock was aquired before you modify it.

    This limitation of this type of behaviour is particularly prevalent in web applications, but is true of anything that uses this approach – Sage Line 50, for one, is a bugger for it, I regularly have to delete lock files after machine/application crashes.

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

Sidebar

Related Questions

I'm about to implement a feature in our application that allows the user to
Can Hibernate implement pessimistic locking at the start of a Java transaction, or does
Implement a link back to a search result page from one of its clicked
To implement data access code in our application we need some framework to wrap
How do I implement a Copy menu item in a Windows application written in
I would like some advice from anyone experienced with implementing something like pessimistic locking
I am trying to implement the jQuery plugin, prettyPhoto, on my page. I used
Implement multi-level hierarchies so that super user have also all rights that sub user
To implement a server supporting clients using web sockets , do servers keep an
Implement an algorithm to merge an arbitrary number of sorted lists into one sorted

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.