好的,所以我一直在使用
PDO wrapper来处理我正在进行的项目,我正在试图找出DELETE查询是否成功.这是我正在使用的代码:
/**
* A pretty straight-forward query to delete a row from the verification
* table where user_id is $user_id and code is $code
*/
$result = $this->database->query("DELETE FROM verification " .
"WHERE user_id = %u AND code = %s",
$user_id,
$code);
/**
* This function will grab the PDO's exec() return, which should
* return the number of rows modified.
*/
if($this->database->getNumAffected($result) > 0)
return true;
else
return false;
问题是,DELETE查询是否实际删除了一行,$this-> database-> getNumAffected($result)始终返回’0′.
你可以查看包装器,但基本上$this-> database-> getNumAffected($result)只返回PDO :: exec()返回的完全相同的值.
我尝试了没有包装器的代码(直接进入PDO),我遇到了同样的问题,但反过来了:它总是返回’1′(是否删除了一行.)
任何帮助将不胜感激.
编辑:基于this问题,我正在做的一切……我不明白为什么这不起作用.