<?php
$user = "root";
$password = "";
$database = "code";
mysql_connect("localhost", $user, $password);
mysql_select_db($database) or die("Unable to select database");
// check if a running process
$query = mysql_query("select * from cats where update_status = 1");
$connections = mysql_num_rows($query);
if ($connections >= 1) {
die("overload");
}
mysql_query("update cats set update_status = 1 where id = 4");
// working....
sleep(50);
mysql_query("update cats set update_status = 0 where id = 4");
mysql_close();
问题在于,当我打电话给这个页面一次,并且在睡眠功能时间内我打开了同一页面的新标签页时,页面继续执行睡眠功能。
应该给“OVERLOAD”?
注意:如果我将此代码复制到新页面(例如test.php)并在睡眠时间内加载它可以工作