I am trying to insert date time in mysql datetime column by using following code but it is not being inserted. while isDelete working fine.
/*
*
* @ORM\Column (type="datetime")
*/
protected $created;
/**
* @ORM\PrePersist
*/
public function prePersist(){
$this->created = new \DateTime("now");
$this->isDelete = 0;
}
Generated schema:
+-----------+------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | | auto_increment |
| isDeleted | tinyint(4) | YES | | 0 | |
| created | datetime | YES | | | |
+-----------+------------+------+-----+---------+----------------+
Any idea?
You’re missing a
*after the/*above yourprotected $createdproperty, so it’s not a docblock comment and ergo isn’t being parsed as an annotation. Thus, the field is not being recognized by Doctrine.It should read:
After you fix this, run the Doctrine schema update tool.