php - Symfony2, set default value of datetime field -
so, have in entity datetime field :
/** * @var \datetime * * @orm\column(name="timestamp", type="datetime") */ private $timestamp;
each time insert in database, : $myentity->settimestamp(new \datetime('now'));
so, want set default value on field in entity, when try :
/** * @var \datetime * * @orm\column(name="timestamp", type="datetime") */ private $timestamp = new \datetime('now');
and after update base doctrine:schema:update
have error : php parse error: syntax error, unexpected 'new' (t_new) in...
how can set default value field ? don't want settimestamp each time use entity... !
you in constructor.
public function __construct(){ $this->timestamp(new \datetime()); }
Comments
Post a Comment