Doctrine 2,最后在事务内插入自动增量键

时间:2016-03-09 12:37:22

标签: mysql doctrine-orm

我创建并持久化(不刷新)数据以确保交易。但是->getId()返回NULL,而MySql最初可以在事务

中返回自动增量值

1 个答案:

答案 0 :(得分:1)

它将为null,但在Flush doctrine将正确处理所有关系。

For the most part, Doctrine 2 already takes care of proper transaction demarcation for you: All the write operations (INSERT/UPDATE/DELETE) are queued until EntityManager#flush() is invoked which wraps all of these changes in a single transaction.

在此处阅读更多内容:http://doctrine-orm.readthedocs.org/projects/doctrine-orm/en/latest/reference/transactions-and-concurrency.html