错误:SQLSTATE [HY000]:常规错误

时间:2018-02-12 17:06:00

标签: php mysql pdo

当我尝试更新数据库中的记录时出现此错误。是因为" fetch"?我知道INSERT不能使用fetch / fetchall,update是一回事吗?

public function inActive($id) {
    $stmt = $this->dbh->prepare("Update " . self::TABLE_NAME . " Set `IsActive`=0 WHERE `ID`=:id");
    $stmt->bindParam(':id', $id);
    return $this->execute($stmt);
}

protected function execute($stmt) {
    $stmt->setFetchMode(PDO::FETCH_CLASS, 'ContactVO');
    $stmt->execute();
    $vo = array();
    try {
        while ($row = $stmt->fetch()) {
            $vo [] = $row;
        }
    } catch (PDOException $e) {
        echo 'Error: ' . $e->getMessage();
    }
    return $vo;
}

0 个答案:

没有答案