0

What features does PHP/MySQL provide to deal with concurrent systems?
E.g, If I have a table, and I only want to allow one user to update at any one time. I want to put a lock on the database until the update is complete, then once that request is processed, unlock the database and allow another user to update?

3
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by nonshatter
0

To my understanding, this is exactly how MyISAM and InnoDB both work with slight differences. MyISAM locks the entire table while InnoDB locks a row during an insert/update.

It appears you can manually lock and unlock a table for a query though if necessary.
http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html

Some info on table locking in mysql
http://dev.mysql.com/doc/refman/5.0/en/table-locking.html
Some info on InnoDB locking
http://dev.mysql.com/doc/refman/5.0/en/innodb-lock-modes.html

0

You can add a timestamp and user columns to the table.
Use these to detect if the table is in use;
For example, if the initial test query returns null time and user, the update query is allowed.

0

Great! Thanks for your responses. I will have play around with what was suggested and get back to you. Thanks.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.