Doctrine - PHP Fatal error: 'Couldn't get last insert identifier.'
I'm having a little issue with Doctrine. Im getting the following error:
PHP Fatal error: Uncaught exception 'Doctrine_Connection_Exception' with message 'Couldn't get last insert identifier.'
I looked at this post, Doctrine Problem: Couldn't get last insert identifier, which was helpful but my problem is a little different.
I'm getting this error on a table that is NOT supposed to have an auto_increment primar开发者_运维技巧y key. My setup is as follows:
Event:
id:int, PK, auto_increment
User
id: int, PK, auto_increment
UserEvent:
user_id:int, PK
event_id: int, PK
I'm having the issue on the insert into the UserEvent. So the flow is, I insert a record into Event, I then insert a record into User, and then I insert a record into UserEvent.
The funny part is, it inserts all 3 of these fine. But after inserting the last one (UserEvent) it throws that error.
Any ideas?
Figured it out -- in the YML schema, UserEvent.user_id and UserEvent.event_id did not have the attribute - primary: true
Once I did that and re-generated the models, the error went away
精彩评论