在 Doctrine 使用 ZF1 和 ZF2 和 MySql 作为数据库的情况下,默认隔离级别是多少?

What is the default Isolation level in case of Doctrine using ZF1 and ZF2 and MySql as database?

我们使用 Doctrine 作为 ORM,框架 ZF1ZF2,以及数据库 MySql。我知道 innodb 引擎的默认隔离级别是 Repeatable Read。由于我使用 Doctrine 作为 ORM,默认的 isolation level 是什么?在此document中表述如下:

The default transaction isolation level of a Doctrine\DBAL\Connection is chosen by the underlying platform but it is always at least READ_COMMITTED.

更让我困惑的是来自学说本身的另一篇文章。我这个document是这样写的:

This could result in unpredictable results because an explicit WITH (NOLOCK) table hint tells SQL Server to run a specific query in transaction isolation level READ UNCOMMITTED instead of the default READ COMMITTED transaction isolation level. Therefore there now is a distinction between LockMode::NONE and null to be able to tell Doctrine whether to add table lock hints to queries by intention or not.

谁能解释一下 Doctrine 的默认隔离级别是多少?

如果您不确定默认隔离级别是什么,您可以使用 SET TRANSACTION ISOLATION LEVEL.

一劳永逸地设置它

您可以使用 Doctrine\DBAL\Driver\ConnectiongetTransactionIsolation() 方法来确定活动事务的隔离级别。

For MySql the default isolation level is Repeatable Read.

For MSSql the default isolation level is Read Committed.

除非您更改中间件 (ORM) 的默认设置,否则以下语句有效:

The default transaction isolation level of a Doctrine\DBAL\Connection is chosen by the underlying platform.