Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine Problem: Couldn't get last insert identifier

Tags:

orm

doctrine

When i try to save data to my model Doctrine throws this exception:

Message: Couldn't get last insert identifier. 

My table setup code is:

$this->hasColumn('id', 'integer', 4, array(
         'type' => 'integer',
         'length' => 4,
         'fixed' => false,
         'unsigned' => false,
         'primary' => true,
         'autoincrement' => true,
         ));

Please help. Thanks.

like image 396
cnkt Avatar asked Apr 12 '10 10:04

cnkt


1 Answers

Check to make sure that the column in your database is set up as auto_increment. It looks like the Doctrine class is handling it as an auto_increment but it's not set up as such in the DB.

like image 150
Thomas Avatar answered Sep 21 '22 06:09

Thomas