symfony 1.4:向模型添加defailt值

时间:2021-04-01 20:19:33

I'd like to add some default values to a model when I'm creating a new entry (like a timestamp)

我想在创建新条目时(如时间戳)向模型添加一些默认值

I'm sure there are more than one way of doing this, I'm curious what the different ways are, but mostly what the standard way of doing this is.

我确信有不止一种方法可以做到这一点,我很好奇不同的方式是什么,但主要是标准的做法是什么。

Thanks

---edit---

solution:

for the timestamp the default would be

对于时间戳,默认值为

default: CURRENT_TIMESTAMP 

1 个解决方案

#1


3  

Use the default key in your schema, like this:

使用架构中的默认密钥,如下所示:

felhasznalok_kezelese:  { type: boolean, default: false }

Works for all field types.

适用于所有字段类型。

#1


3  

Use the default key in your schema, like this:

使用架构中的默认密钥,如下所示:

felhasznalok_kezelese:  { type: boolean, default: false }

Works for all field types.

适用于所有字段类型。