Php Symfony实体日期时间字段更新失败

Php Symfony实体日期时间字段更新失败,php,symfony,datetime,doctrine,Php,Symfony,Datetime,Doctrine,我正在做一个Symfony项目。在其中一个实体中,我必须更新Datetime字段,但每次我创建一个新的Datetime对象并将其设置为我的实体属性并调用flush函数时,我都会收到一个错误,提示: An exception occurred while executing UPDATE tablename SET update = ? WHERE id = ? with params ["2015-04-23 15:31:50", 2] 仅供参考:如果不更新Datetime字段,一切正常 //

我正在做一个Symfony项目。在其中一个实体中,我必须更新Datetime字段,但每次我创建一个新的Datetime对象并将其设置为我的实体属性并调用flush函数时,我都会收到一个错误,提示:

An exception occurred while executing UPDATE tablename SET update = ? WHERE id = ? with params ["2015-04-23 15:31:50", 2]
仅供参考:如果不更新Datetime字段,一切正常

//Here is what I set to the Datetime field:
$eo->setUpdate();

//The function in the Entity
public function setUpdate() {
    $this->update = new \DateTime('now', new \DateTimeZone('UTC'));

    return $this;
}

//And the field declaration
/**
 * @var \DateTime
 *
 * @ORM\Column(name="update", type="datetime", nullable=false)
 */
private $update;
编辑:

我忘了这个:

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 = "2015-04-23 15:53:29" WHERE id = 2" at line 1

你知道我为什么会出现这种异常吗?

因此,基本上错误是因为我在数据库中使用了保留字更新作为列名-_-


感谢@Nemutaisama帮我解决了这个问题。由于他没有发布此问题的答案,我正在这样做,希望它能帮助其他人。

您是否检查了可运行查询?错误怎么说?不确定这是否是您的问题,但确定使用保留字更新列名是错误的做法我只是编辑了这篇文章以添加sql错误@Nemutaisama是的,我考虑过这一点,并试图更改酒店名称。但是运气不好。可能是因为表的更新字段名吗?因为我已经更改了实体的属性名,但没有更改表中的实际字段名是的,这是原因-将表字段名更改为已更新,如示例所示