yiisoft/yii2 · error · yii\base\NotSupportedException
Transaction not started: nested transaction not supported.
Error message
Transaction not started: nested transaction not supported.
What it means
Error "Transaction not started: nested transaction not supported." thrown in yiisoft/yii2.
Source
Thrown at framework/db/Transaction.php:148
Yii::debug('Begin transaction' . ($isolationLevel ? ' with isolation level ' . $isolationLevel : ''), __METHOD__);
$this->db->trigger(Connection::EVENT_BEGIN_TRANSACTION);
$this->db->pdo->beginTransaction();
$this->_level = 1;
return;
}
$schema = $this->db->getSchema();
if ($schema->supportsSavepoint()) {
Yii::debug('Set savepoint ' . $this->_level, __METHOD__);
// make sure the transaction wasn't autocommitted
if ($this->db->pdo->inTransaction()) {
$schema->createSavepoint('LEVEL' . $this->_level);
}
} else {
Yii::info('Transaction not started: nested transaction not supported', __METHOD__);
throw new NotSupportedException('Transaction not started: nested transaction not supported.');
}
$this->_level++;
}
/**
* Commits a transaction.
* @throws Exception if the transaction is not active
*/
public function commit()
{
if (!$this->getIsActive()) {
throw new Exception('Failed to commit transaction: transaction was inactive.');
}
$this->_level--;
if ($this->_level === 0) {
Yii::debug('Commit transaction', __METHOD__);
// make sure the transaction wasn't autocommittedView on GitHub (pinned to 66f00d18a2)
When it happens
Trigger: Thrown at framework/db/Transaction.php:148 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of yiisoft/yii2@66f00d18a2 (2026-08-17).
Data as JSON: /api/errors/9c7106b6b1374358.
Report an issue: GitHub.