时间有点神秘: 我得到了这个查询:
$stmt = 'update wp_term_relationships set term_taxonomy_id = :newID '.
'where term_taxonomy_id= :oldID and object_id = :postID';
self::$stmtSetNewID = self::$dataBase->prepareStatement($stmt);
[...]
self::$stmtSetNewID->bindParam(':oldID', $oldCatID, PDO::PARAM_INT);
self::$stmtSetNewID->bindParam(':newID', $newCatID, PDO::PARAM_INT);
self::$stmtSetNewID->bindParam(':postID', $postID, PDO::PARAM_INT);
$result = self::$stmtSetNewID->execute();
$rowCount = self::$stmtSetNewID->rowCount();
echo $rowCount;
我尝试设置错误级别
$this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
并输出可能的错误
var_dump(self::$stmtSetNewID->errorInfo());
并输出受影响行的计数(在上面代码的末尾)。
没有错误,没有警告,没有。 rowCount()
返回1,但数据库中的值保持不变。
对我来说,看起来PDO /数据库说一切正常,但没有!
我很沮丧,并且会欣赏每一个提示!谢谢!
更新:
echo "\nPostID: $postID | oldID: $oldCatID ".
"| newID: $newCatID | rowCount: $rowCount\n<br/>\n";
输出的值是正确的,$rowCount
是1:
PostID: 5432 | oldID: 3 | newID: 32 | rowCount: 1
PostID: 5435 | oldID: 3 | newID: 8 | rowCount: 1
答案 0 :(得分:0)
好的伙计们,明白了。很抱歉浪费你的时间在我的愚蠢上。正如脚本所说,更新执行没有错误。但是我在我的脚本中更新了帖子,这次更新覆盖了我的新设置类别。