我使用以下代码来节省时间。我已经尝试将我的列类型更新为DATETIME和TIMESTAMP
$statement = $conn->prepare('UPDATE users SET update = :update WHERE id = :clientId');
$statement->bindParam(':clientId', $clientId, PDO::PARAM_STR);
$statement->bindParam(':update', time(), PDO::PARAM_STR);
$statement->execute();
{"error":"SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'update = '1367692928' WHERE id = 'I9pm90r-b4'' at line 1"}
答案 0 :(得分:0)
update
是保留关键字,恰好是您列的名称。为了避免语法错误,应使用反引号转义列名称。前,
UPDATE users SET `update` = :update WHERE id = :clientId
如果您有权更改表格,请更改保留关键字列表上不存在的列名称,以防止同一错误再次返回。