×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

record locking

record locking

record locking

(OP)
Simple question to an age old problem:

How do you guys handle record locking in PHP/MySQL applications?

--
SouthBeach
http://www.fp2php.com
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.

RE: record locking

I've never found it to be a problem, as there is only ever one 'user' accessing the data, and the operations/transactions are, for all intents and purposes, instantaneous. Record locking is really only necessary when "slowpoke" humans are involved and opening queries then staring intently at the information for maybe, .... oooh whole seconds before making a decision to do something. PHP transactions are more of a Connect -> Query -> Gone style and the time between "Connect" and "Gone" is measured in milliseconds.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: record locking

(OP)
Here is my scenario:
1) SELECT and echo to render a data grid
2) User clicks on row and triggers
3) SELECT and echo to render a full page record

At this point, user has chosen to edit a row. As you said, the process time to get to this point is not even a second.

Now, imagine an office with 5 or more people handling calls and attempting to access the same row (full record mode) at once.

As of this moment, whomever [ SAVE ] last, retains content.

Normally, in a multiuser environment, record locking is always a concern and I hate the idea of "tagging the record as locked" by setting a field since the same user that just opened the record, can walk away, close the browser, let the session expire or simply spend the rest of the day in social media.

One option is to tag the record as "locked" upon opening the "full record mode page", and run a cron process to scan for "locked" rows set 3 minutes ago or later and unset them.

--
SouthBeach
http://www.fp2php.com
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.

RE: record locking

Okay, If your database is using the MyISAM engine you can only 'lock' at table level, to use row level locking you need to be using the InnoDB storage engine,

http://dev.mysql.com/doc/refman/5.7/en/internal-lo...

You don't really need a cron task to release the locks as SET_LOCK() takes a timeout value.

Then again, one of our hosting clients has a website that using PHP & MySQL that is accessed by website customers and a seven strong sales team with no 'locking' in place, without any "collision issues".

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close