本文介绍了原则问题:无法获取最后一个插入标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试将数据保存到我的模型时,Doctrine会抛出以下异常:

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

Message: Couldn't get last insert identifier. 

我的表设置代码是:

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

请帮忙。谢谢。

推荐答案

检查以确保数据库中的列设置为auto_increment。看起来Doctrine类正在处理它作为一个auto_increment,但它不是像DB那样设置。

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.

这篇关于原则问题:无法获取最后一个插入标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 00:28