復制代碼 代碼如下:
mysql>lock table userstat read;
mysql>unlock tables;
復制代碼 代碼如下:
//執行SQL語句 鎖掉stat_num表
$sql = "LOCK TABLES stat_num WRITE"; //表的WRITE鎖定,阻塞其他所有mysql查詢進程
$DatabaseHandler->exeCute($sql);
//執行更新或寫入操作
$sql = "UPDATE stat_num SET `correct_num`=`correct_num`+1 WHERE stat_date='{$cur_date}'";
$DatabaseHandler->exeCute($sql);
//當前請求的所有寫操作做完后,執行解鎖sql語句
$sql = "UNLOCK TABLES";
$DatabaseHandler->exeCute($sql);
新聞熱點
疑難解答