Doctrine throws an Exception “Couldn’t get last insert identifier.”

Posted: July 10th, 2009 | Author: Marc | Filed under: easier | Tags: , , , | 2 Comments »

If Doctrine throw “Couldn’t get last insert identifier.” exception to your face, you might want to check the schema.yml of your table and change all your:

type: int

to

type: integer

Here is an exemple:
THIS IS BAD:

1
2
3
4
5
6
7
8
MyModel:
  actAs:
    Timestampable:     ~
  columns:
    id:
      type:             int(4)
      primary:          true
      autoincrement:    true

THIS IS GOOD:

1
2
3
4
5
6
7
8
MyModel:
  actAs:
    Timestampable:     ~
  columns:
    id:
      type:             integer(4)
      primary:          true
      autoincrement:    true

This might solve your problem.


2 Comments on “Doctrine throws an Exception “Couldn’t get last insert identifier.””

  1. 1 Malte said at 02:08 on July 20th, 2009:

    Hello,

    Thank you! I had exact this Error and now it’s gone…

    Keep up your good work…!

    Malte

  2. 2 Daniel said at 23:29 on November 26th, 2009:

    Had the same error. Thanks!


Leave a Reply