现在的位置: 首页 > 综合 > 正文

php锁表

2013年08月02日 ⁄ 综合 ⁄ 共 328字 ⁄ 字号 评论关闭

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

抱歉!评论已关闭.