我是一名php新手,并在web服务上工作,从iphone端增加itemQuantity。当用户点击+按钮多次增加一个项目的数量时,它有时会不准确地增加数量。 iPhone每次都会向我发送增加的数量。我的意思是26然后27然后28.先来先服务php
但是,当我试图调试它,我发现有一段时间它首先服务数据库与28然后更新到27。任何人都可以帮忙吗?我使用的功能如下....
function update_query($tblName,$queryArr,$condition)
{
if(!empty($this->_database)){
if(!mysql_select_db($this->_database, $this->_link))
{
$this->_errorstr = "Couldn't change database: ".$this->_database."
My-SQL Error ".mysql_error($this->_link);
}
}
[email protected]_keys($queryArr);
[email protected]_values($queryArr);
$update="";
for($i=0;$i<count($values);$i++)
{
$update.="$fields[$i]='".addslashes($values[$i])."',";
}
$update=substr($update,0,-1);
$query="update $tblName set $update $condition";
// echo $query
//echo $query."<br>";
//die;
$this->_errorstr = "";
$this->_query = $query;
$this->_result = mysql_query($this->_query, $this->_link);
if (! $this->_result)
{
$this->_errorstr = "Error : ".mysql_error($this->_link);
$this->_success = false;
}
else
{
$this->_success = true;
}
return $this->_success;
}
删除那些'@'符号,您可能会看到错误... – Neal
您的请求是否以正确的顺序从iPhone到达? – Marcus
您是否每次用户点击手机上的增加数量按钮时都会发送一个请求? – jprofitt