How to define current timestamp in yaml with doctrine?

前端 未结 7 1052
灰色年华
灰色年华 2020-12-09 18:41

I tried the following yaml code:

columns:
  created_time:
    type: timestamp
    notnull: true
    default: default CURRENT_TIMESTAMP

In

7条回答
  •  囚心锁ツ
    2020-12-09 19:14

    I suggest not to use "default" for timestamp at all.

    It will bring unpredictable state in yaml in your application. This video (PHP UK Conference 2016 - Marco Pivetta - Doctrine ORM Good Practices and Tricks) provides some more information about this topic. I suggest you to to go through it and create a named constructor.

    public function createTimestamp(string $priority, int $priorityNormalized)
    {
        $this->priority = $priority;
        $this->priorityNormalized = $priorityNormalized;
    }
    

    I suggest to be stateless, good luck!

提交回复
热议问题