Table for reading and writing

How to lock a table for reading and writing using php? Here is what I tried with no luck.

mysql_query("LOCK TABLES table WRITE;"); mysql_query("LOCK TABLES table READ, WRITE;"); mysql_query("LOCK TABLES table READ WRITE;"); 

Here is my mistake:

You have an error in the SQL syntax; check the manual that matches your version of MySQL server for the correct syntax to use next to "WRITE" on line 1

+6
source share
1 answer
 mysql_query("LOCK TABLE table WRITE"); // you might think it 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 cannot acquire multiple locks for the same table without imposing them on aliases. Read the manual .

+4
source

Source: https://habr.com/ru/post/900617/


All Articles