php锁表

用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);

posted on 2014-02-18 10:52  BuildyMan  阅读(601)  评论(0编辑  收藏  举报

导航