Gig*_*iga 5 php symfony doctrine-orm
我正在做app,我使用SQL,我想在一列中保存复选框值.我是这样做的:
/**
* @Assert\NotBlank(
* message="please select!")
* @Assert\NotNull(
* message="please select!")
* @Assert\Range(min=0, max=9)
* @ORM\Column(type="integer")
*/
protected $ingredients;
public static function getIngredientsOptions(){
return array('cheese','tomatoes','salami','onions','mushroom','bacon','ham','vegetables','peppers','olives');
}
Run Code Online (Sandbox Code Playgroud)
但我得到错误,说我有SELECT错误,我认为问题是复选框.它是否正确?你能帮帮我怎么做吗?
sek*_*ekl 14
您可以将列类型更改为"数组",如下所示:
@ORM\Column(name="ingredients", type="array", nullable=true)
Run Code Online (Sandbox Code Playgroud)
这将导致带有注释"(DC2Type:array)"的longtext字段,因此Doctrine知道如何处理它.它将存储一个序列化数组.
这可能就是你想要的.如果没有,请发布一些使用表单的setter和controller的代码,以及错误消息.
| 归档时间: |
|
| 查看次数: |
6104 次 |
| 最近记录: |