PDO:UPDATE无效

时间:2015-08-16 15:04:29

标签: php mysql pdo sql-update

我写了一些代码来通过php / PDO更新mySQL表。 但它无法正常工作,我无法弄清楚我的错误在哪里 execute()返回true,但更改实际上从未显示在表中。

我的代码看起来非常像这样:

$columnObject = array(
    "emailAddress"=>"aaa@aaa.com",
    "passwordHash"=>"56bj5g63j4g57g567g5k75jh7gk4g74j5hg67",
    "name"=>"qweqweqwe",
    "lastActivity"=>4128649814
);
$knownColumnName = "emailAddress";
$knownColumnData = "aaa@aaa.com";

foreach ($columnObject as $columnName => $columnData) {
    $pdoUpdateString .= $columnName . "=:" . $columnName . ",";
    $pdoExecuteObject[$columnName] = $columnData;
}
$pdoUpdateString = rtrim($pdoUpdateString, ",");

$pdoExecuteObject['knownColumn'] = $knownColumnData;
$q = $this->hCon->prepare('UPDATE ' . $this->name . ' SET ' . $pdoUpdateString . ' WHERE ' . $knownColumnName . '=:knownColumn');
$q->execute($pdoExecuteObject);

0 个答案:

没有答案