Reputation: 147
How to lock table for reading and writing with php? Here is what I tried without luck.
mysql_query("LOCK TABLES table WRITE;");
mysql_query("LOCK TABLES table READ, WRITE;");
mysql_query("LOCK TABLES table READ WRITE;");
Here is the error I got:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WRITE' at line 1
Upvotes: 8
Views: 5760
Reputation: 45599
mysql_query("LOCK TABLE table WRITE"); // you might think it's here
mysql_query("LOCK TABLE table READ, table AS t2 WRITE"); // <- but the error is here
mysql_query("LOCK TABLES table READ, table as t2 WRITE"); // <- ...and here.
You can not acquire multiple locks for the same table without aliasing it. Read the manual.
Upvotes: 5