3

假设我的 YAML 方案看起来像这样:

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 (lenght) 的第二个验证器错误:-)

4

2 回答 2

2

我知道了。用“integer”替换“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

我试过了,因为网上的其他人也有类似的错误,解决了用“string”替换“varchar”的问题。

如果有人陷入其中并阅读了此答案,请以他们的名义喝啤酒:-)

于 2009-05-30T10:40:49.273 回答
0

我知道这是老...

我只是想我可以澄清一下有效的学说类型是“整数”、“字符串”、“浮点数”、“十进制”、“对象”、“clob”、“blob”、“enum”、“array”。

然后,Doctrine 将教义类型转换为所选后端的正确数据库类型。

这就是为什么“int”未能通过类型验证器,但“integer”有效。

于 2009-09-28T21:55:53.027 回答