2011-11-02 21 views
6

Cómo bloquear la tabla para leer y escribir con php? Esto es lo que intenté sin suerte.Bloquear tabla para leer y escribir

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

Aquí está el error que tengo:

Usted tiene un error en su sintaxis SQL; consulte el manual que corresponde a su versión del servidor MySQL para el sintaxis derecho al uso cerca de 'escribir' en la línea 1

+0

y ¿qué pasó? – glglgl

+0

y la primera afirmación debería estar bien. ¿Qué es eso que no funciona? ¿Está dando un error? ¿No pone el bloqueo de ESCRITURA? – Abhay

+0

pruébelo sin el ';' – dnagirl

Respuesta

4
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. 

No se puede adquirir múltiples cerraduras para la misma mesa sin aliasing ella. Read the manual.