我正在尝试以这种方式将默认值设置为yml文件上的profile_percentage字段
...
....
profilePercentage:
type: float
column: profile_percentage
nullable: false
options:
comment: Profile surveys completed percentage
default: 0
为了避免手动设置字段
$client->setProfilePercentage(0.0);
但是使用此配置,我会收到以下消息:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'profile_percentage' cannot be null
最佳答案
默认值不是100%可移植的,在理论上最安全的方法是在实体构造函数中。
关于php - SQLSTATE [23000]:违反完整性约束:1048 Doctrine 上,列'profile_percentage'不能为空,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51820284/