views:

766

answers:

3

Let's say that I have YAML scheme looking like that :

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

When performing :

$note->setOrderId(0);
$note->save();

I'm getting the following error :

1 validator failed on order_id (type)

MySQL store order_id as bigint(20).

I am using Ubuntu 9.10, Symfony 1.2, PHP 5 and MySQL 5.

EDIT :

Got a hint, if I remove all mention of the size in the YAML file, I get a second validator error for order_id (lenght) :-)

+1  A: 

I got it. Replacing "int" by "integer" and getting rid of the size did the trick. Now the YAML file looks like :

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

I tried that because other people on the net had similar errors, solved replacing "varchar" with "string".

If someone get stuck into that and read this answer, have a beer in their names :-)

e-satis
+1  A: 

I know this is old...

I just thought I might clarify that valid doctrine types are "integer", "string", "float", "decimal", "object", "clob", "blob", "enum", "array".

Doctrine then translates the doctrine type into the correct database type for the chosen backend.

Thats why "int" failed the type validator, but "integer" works.

Palo Verde
A: 

Just wanted to add that doctrine also supports boolean

Kat Lim Ruiz