code_junkie

Locking a MySQL database so only one person at once can run a query?

Nov 13th, 2011
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. LOCK TABLES items;
  2. START TRANSACTION;
  3. INSERT INTO items (name, label) VALUES ('foo', 'bar');
  4. UNLOCK TABLES;
  5.  
  6. mysql_query('LOCK TABLES items');
  7. mysql_query("INSERT INTO items (name, label) VALUES ('foo', 'bar')");
  8. mysql_query('UNLOCK TABLES');
Add Comment
Please, Sign In to add comment