Par*_*der 6 doctrine doctrine-orm
我正在尝试在Doctrine 2.1中定义一个列(使用注释),该列映射到MySQL中的固定长度CHAR列.使用fixed = true不能完成这项工作.注释
* @ORM\Column(type="string", length=49, fixed=true, nullable=false)
Run Code Online (Sandbox Code Playgroud)
它会导致错误:"在属性[name here]上声明的注释@ORM\Column没有名为"fixed"的属性.可用属性:name,type,length,precision,scale,unique,nullable,options,columnDefinition ".所以我假设"固定"位需要在"选项"中传递.但是怎么样?我已经搜索了Doctrine 2.1文档,但却找不到任何相关内容.
我试过了
* @ORM\Column(type="string", length=49, options="fixed=true", nullable=false)
Run Code Online (Sandbox Code Playgroud)
这不会导致错误,但会被忽略 - 创建的列是VARCHAR(49).
我不想使用columnDefinition.
有什么建议?
谢谢
小智 7
正确的语法是这样的:
@ORM\Column(type="string", length=49, options={"fixed":true}, nullable=false)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3651 次 |
| 最近记录: |