Posted on 2008-10-07 08:29
David.Ko 阅读(3986)
评论(2) 编辑 收藏 所属分类:
DataBase
转自:http://www.pai7.cn/article.asp?id=359
SQL语句:
LOCK TABLES tablename WRITE;
LOCK TABLES tablename READ;
Insert INTO assignment VALUES (1,7513,'0000-00-00',5),(1,7513,'2003-01-20',8.5);
UNLOCK TABLES;
对于多个用户同时提交表单,并且同时向数据库中得到表单ID,我是这样解决的:
mysql_query("lock tables po read");
mysql_query("lock tables po write");
mysql_query("update po set id=id +1"));// increase po id
$sql = "Select id FROM po";
$result = mysql_query($sql);
if ($row = mysql_fetch_assoc($result)) {
echo $row["id"]; // this order will use this id
}
mysql_free_result($result);
mysql_query("unlock tables");