Orm 条令问题:不能';无法获取最后一个插入标识符

Orm 条令问题:不能';无法获取最后一个插入标识符,orm,doctrine,Orm,Doctrine,当我尝试将数据保存到模型时,会引发以下异常: Message: Couldn't get last insert identifier. 我的表格设置代码是: $this->hasColumn('id', 'integer', 4, array( 'type' => 'integer', 'length' => 4, 'fixed' => false, 'unsigned' => false

当我尝试将数据保存到模型时,会引发以下异常:

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,
         ));
请帮忙。谢谢。

这对我很有用:

$this->hasColumn('cd_fabricante', 'integer', 4, array(
          'type' => 'integer',
          'length' => 4,
          'unsigned' => true,
          'primary' => true,
          'auto_increment' => true,
) );
与您之前的参数相同,错误也相同


编辑:我最近发现关于将“自动增量”添加到PK列定义中,现在我发现它的行为与Doctrine使用我选择的任何名称处理的任何给定ID字段相同,请检查以确保数据库中的列设置为自动增量。看起来Doctrine类正在将其作为自动增量处理,但在DB中没有这样设置。

对我来说,问题在于
默认值
参数

        $this->hasColumn('inscription_id', 'integer', 4, array(
         'type' => 'integer',
         'length' => 4,
         'fixed' => false,
         'unsigned' => false,
         'primary' => true,
 //        'default' => '0', !!! get "couldn't get last inserted identifier doctrine"
         'notnull' => true,
         'autoincrement' => true,
         ));

我希望我能不止一次投这一票。你刚刚犯了一个大错误,有10分钟的修复时间。