Lock mysql table with php

后端 未结 4 1151
长情又很酷
长情又很酷 2020-12-11 18:01

Script 1.

$query_ = \"lock tables test1 as test11 write\";
mysql_query($query);
$query_ = \"select * from test11\";
sleep(20);
$query_ = \"unlock tables\";
m         


        
4条回答
  •  半阙折子戏
    2020-12-11 18:09

    If you do not want others to access that table then use

    LOCK TABLES test1 WRITE;
    

    Other script will not return error but will wait until lock is released.

    Hope it helps...

提交回复
热议问题