如何使用学说在 yaml 中定义当前时间戳? [英] How to define current timestamp in yaml with doctrine?
本文介绍了如何使用学说在 yaml 中定义当前时间戳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试了以下yaml代码:
I tried the following yaml code:
columns:
created_time:
type: timestamp
notnull: true
default: default CURRENT_TIMESTAMP
在输出的sql语句中,该字段被视为日期时间而不是时间戳,我无法在其中定义当前时间戳...
In the outputted sql statement, the field is treated as datetime instead of timestamp, which I cannot define the current timestamp in it...
如果我坚持使用时间戳来存储当前时间,在yaml中怎么做?
If I insist to use timestamp to store current time, how to do so in yaml?
推荐答案
你可以在学说中使用'Timestampable'功能,例如:
You could use the 'Timestampable' functionality in doctrine, eg:
actAs:
Timestampable:
created:
name: created_time
updated:
disabled: true
columns:
created_time:
type: timestamp
notnull: true
这篇关于如何使用学说在 yaml 中定义当前时间戳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文