How to define current timestamp in yaml with doctrine?

前端 未结 7 1060
灰色年华
灰色年华 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!

    0 讨论(0)
提交回复
热议问题