I am having a few issues when people are trying to access a MySQL database and they are trying to update tables with the same information.
I have a webpage written u
You're looking for LOCK
.
http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html
This can be run as a simple mysql_query
(or MySQLi::query/prepare
).
I'd say it's better to lock specific tables (although you can probably try LOCK TABLES *
) that need to be locked rather than the whole database - as nothing will be able to be read. I think you're looking for something like:
LOCK TABLES items;
START TRANSACTION;
INSERT INTO items (name, label) VALUES ('foo', 'bar');
UNLOCK TABLES;
Or in PHP:
mysql_query('LOCK TABLES items');
mysql_query("INSERT INTO items (name, label) VALUES ('foo', 'bar')");
mysql_query('UNLOCK TABLES');