开发者

how to define an autoincrement id column in doctrine?

I'm using symfony 1.4 with doctrine as my ORM, I need to do one of two thing to get it working, and I don't know how to do it.

  1. the id fields should not be bigint, j开发者_StackOverflowust int or

  2. When I define my table as follows:

    Table:
      columns:
        id:
        type: integer
        autoincrement: true
        primary: true
    

make the autoincrement work, because if I define my id like so it won't autoincrement it.


Autoincremented Id keys are automatically added by Doctrine if you do not specify one explicitly.

This should work as expected:

columns:
  nextfield: string

or:

columns:
  id:
    type: integer(2)
    autoincrement: true
    primary: true
  nextfield: string


For the integer data type, check this out: http://www.symfony-project.org/doctrine/1_2/en/04-Schema-Files

For the auto-increment...

  primary: true
  autoincrement: true

... should be all you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜