函数有一个结构:MySQL的MyISAM的竞争条件
$q = 'LOCK TABLES table1 WRITE;';
mysql_query($q);
$q = 'select id from table1 where is_delete = 0 limit 1;';
$res = mysql_fetch_assoc(mysql_query($q));
if($res) {
$q = 'UPDATE table1 SET is_delete = 1 WHERE id = '".$res['id']."'';
mysql_query($q);
}
$q = 'UNLOCK TABLES;';
mysql_query($q);
我锁定所有的表,但查询的并行运行。 这个怎么解决?
哪里锁定表的代码? – 2012-04-16 18:56:59
对不起,问题更新 – Merlin 2012-04-16 19:02:53
您的用户是否拥有LOCK TABLES特权? – angrychimp 2012-04-16 19:30:55