1
我正在尝试运行表的特定行的更新,并在每次运行更新时增加一列的内容。但是在某些时候,查询不会运行,也不会产生异常。有谁知道为什么会发生这种情况?我曾尝试以下:mysql_query&update查询未执行
$intVersion = $this->intVersion + 1;
$strSql=<<<EOT
UPDATE $this->strQueryTable SET version = '$intVersion' WHERE id = $this->id;
EOT;
$blnQueryOk = mysql_query ($strSql);
$intVersion = $this->intVersion + 1;
$strSql =<<<EOT
UPDATE $this->strQueryTable SET version = $intVersion WHERE id = $this->id;
EOT;
$blnQueryOk = mysql_query ($strSql);
$strSql =<<<EOT
UPDATE $this->strQueryTable SET version = version + 1 WHERE id = $this->id;
EOT;
$blnQueryOk = mysql_query ($strSql);
,并在所有的情况下:
if (!$blnQueryOk) {
throw new Exception(mysql_error());
return false;
}
他们全部失败,但不会产生异常更新一些时间。
首先 - 使用此语法{$ foo的}用于使变量到SQL你的情况 – SergeS
为$这个 - > ID有点不你期待什么呢? – Randy
如果您认为查询失败,请使用http://us2.php.net/mysql_error echo $ strSql并查看您实际发送的内容,并且您应该真正使用某种转义策略:http:/ /us2.php.net/manual/en/function.mysql-real-escape-string.php – Jody