Man*_*ari 1 php entity doctrine symfony
我必须在学说实体的注释中输入什么?
其实是这样的...
/**
* @ORM\Column(type="string", length=255)
*
* @Assert\Length(
* min=3,
* max=255,
* minMessage="The name is too short.",
* maxMessage="The name is too long.",
* groups={"Registration", "Profile"}
* )
*/
protected $name;
Run Code Online (Sandbox Code Playgroud)
我必须告诉教义类似的东西canBeNull=true。否则我总是会收到这个错误SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null
但是代码是什么?
将COLUMN 属性中的属性可为null定义为true。
例子:
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Assert\Length(
* min=3,
* max=255,
* minMessage="The name is too short.",
* maxMessage="The name is too long.",
* groups={"Registration", "Profile"}
* )
*/
protected $name;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2483 次 |
| 最近记录: |