我正在尝试使用以下代码在 mysql datetime 列中插入日期时间,但它没有被插入。而 isDelete 工作正常。
/*
*
* @ORM\Column (type="datetime")
*/
protected $created;
/**
* @ORM\PrePersist
*/
public function prePersist(){
$this->created = new \DateTime("now");
$this->isDelete = 0;
}
生成的架构:
+-----------+------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | | auto_increment |
| isDeleted | tinyint(4) | YES | | 0 | |
| created | datetime | YES | | | |
+-----------+------------+------+-----+---------+----------------+
任何想法?