【发布时间】:2011-09-29 11:16:06
【问题描述】:
我有一个奇怪的问题。
这是我的 yaml:
Request:
actAs: { Timestampable: ~ }
columns:
id: { type: integer(4), primary: true, autoincrement: true, notnull: true }
当我在我的BaseRequest.class.php 中执行 symfony doctrine:build --all --no-confirmation 时,我的 id 字段声明期间出现错误:
$this->hasColumn('id', 'integer', 4, array(
'type' => 'integer',
'primary' => true,
'autoincrement' => true,
'length' => 4,
));
如您所见,它应该是 auto_increment 但它是自动增量,所以我必须在每次构建后手动更改它。
有没有办法解决这个问题?
【问题讨论】:
-
究竟是什么让你说它应该是
auto_increment而不是autoincrement?我的一个模型中有这个声明,autoincrement,在 MySQL 中,我可以看到auto_increment,它工作正常。 -
这在 mySQL 中很好,但是当我尝试保存我的项目时,我得到“无法获取最后一个插入标识符”,当我更改为 auto_increment 时它可以工作。
-
插入新行后,mysql中
SELECT LAST_INSERT_ID();返回什么? -
它返回 0,我不知道为什么。
-
这两种情况你都试过了吗?有什么区别吗?另外,当你做
SHOW CREATE TABLE your_table时有什么不同吗?
标签: php symfony1 symfony-1.4 yaml