轉自: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");
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");