php锁表

xiaoxiao2021-02-28  53

用PHP实现mysql锁表

mysql锁表,是利用相关的SQL语句

//执行SQL语句 锁掉userinfo表

$sql = "LOCK TABLES userinfo WRITE";

//表的WRITE锁定,阻塞其他所有mysql查询进程

$Database->execute($sql);

//执行更新或写入操作

$sql = "UPDATE userinfo SET `correct_num`=`correct_num`+1 WHERE stat_date='{$current_date}'";

$Databaser->execute($sql);

//当前请求的所有写操作做完后,执行解锁sql语句

$sql = "UNLOCK TABLES";

$Database->execute($sql);

转载请注明原文地址: https://www.6miu.com/read-80296.html

最新回复(0)