为什么我得到“验证失败”一个保存在Symfony 1.2的学说?
问题描述:
比方说,我有YAML方案看起来就像是:为什么我得到“验证失败”一个保存在Symfony 1.2的学说?
Note:
options:
type: MyISAM
collate: utf8_unicode_ci
charset: utf8
actAs: { Timestampable: ~ }
columns:
content: { type: string, notnull: true}
order_id: int(5)
user_id : int
relations:
User:
foreignAlias: Notes
local: user_id
foreign: id
type: one
foreignType: man
onDelete: CASCADE
当执行:
$note->setOrderId(0);
$note->save();
,我发现了以下错误:
1 validator failed on order_id (type)
MySQL的商店ORDER_ID为BIGINT (20)。
我使用Ubuntu 9.10,Symfony的1.2,PHP 5和MySQL 5
编辑:
得到了暗示,如果我删除的文件YAML的大小都不在话下,我得到一个第二order_id(长度)验证错误:-)
答
我明白了。用“整数”替换“int”并去掉大小就是个窍门。现在YAML文件看起来像:
Note:
options:
type: MyISAM
collate: utf8_unicode_ci
charset: utf8
actAs: { Timestampable: ~ }
columns:
content: { type: string, notnull: true}
order_id: integer
user_id : integer
relations:
User:
foreignAlias: Notes
local: user_id
foreign: id
type: one
foreignType: man
onDelete: CASCADE
我想,因为其他人在网络上也有类似的错误,解决了“串”代替“VARCHAR”。
如果有人陷成和阅读这个答案,在他们的名字啤酒:-)
答
我知道这是老了......
我只是想我会澄清,有效的原则类型是“整数”,“字符串”,“浮点数”,“十进制”,“对象”,“clob”,“blob”,“枚举”,“数组”。
然后,Doctrine将原则类型转换为所选后端的正确数据库类型。
这就是为什么“int”失败的类型验证程序,但“整数”的作品。
我有同样的问题,但在1.4。我在模式中将“字符串”更改为“浮点数”...但在save()上我有这个错误。 – Manu 2012-04-24 08:52:28