php - Saving time() IN Mysql -
i using following code save time. have tried updating column type datetime , timestamp
$statement = $conn->prepare('update users set update = :update 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 have error in sql syntax; check manual corresponds mysql server version right syntax use near 'update = '1367692928' id = 'i9pm90r-b4'' @ line 1"}
update
reserved keyword , happens name of column. in order avoid syntax error, column name should escaped using backticks. ex,
update users set `update` = :update id = :clientid
if have privilege alter table, change column name not on reserved keyword list prevent same error getting again on future.
Comments
Post a Comment