php - How can I get Gedmo\Timestampable to keep updated_at null on first create? -


i've got symfony 2.8 app uses gedmo\timestampable annotations automatic created_at , updated_at operations, seems putting same timestamp updated_at column when entity/row first created. update cause updated_at column show newer timestamp, want blank begin with.

my understanding on insert, created_at column should populated timestamp , updated_at should stay blank, because hasn't been updated such. after first update of column should value of updating time.

am correct in expecting this? there wrong code/config? or annotation set values both columns design?

my config.yml:

... stof_doctrine_extensions:     default_locale: "%locale%"     translation_fallback: true     orm:         default:             translatable: true             timestampable: true ... 

my entity:

... /**  * automatic timestamp of creation.  *  * @var \datetime $createdat  * @gedmo\timestampable(on="create")  * @orm\column(name="created_at", type="datetime")  */ public $createdat;  /**  * automatic timestamp of updation.   *  * @var \datetime $updatedat  * @gedmo\timestampable(on="update")  * @orm\column(name="updated_at", type="datetime")  */ protected $updatedat; ... 

the table defines 2 columns datetime , have no default clauses.

this done design, can see if open file "vendor/gedmo/doctrine-extensions/lib/gedmo/timestampable/timestampable.php", line 22 (on version of gedmo):

/**                                                                                                                                                                                                                                                                             * @gedmo:timestampable(on="update")                                                                                                                                                                                                                                            * dates should updated on update , insert                                                                                                                                                                                                                           */  

after all, insert kinda update of table / record well. if need know whether object freshly created or not, still perform check between date stored in "createdat" , 1 stored in "updatedat".


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -