CoolCMS API

OwnedTransaction
in package

FinalYes

Cleans up a bare DBAL transaction (outside {@see TransactionManager}) in a catch block by rolling back only the level the caller opened.

After a failed commit DBAL has usually closed the transaction already, so a blind rollBack() would throw "No active transaction" (masking the real error) or, in a nested run, roll back the caller's savepoint or transaction. A rollback failure is only logged; the original exception stands.

Usage:

$level = $conn->getTransactionNestingLevel();
$conn->beginTransaction();
try { $conn->commit(); } catch (\Throwable $e) { OwnedTransaction::rollBack($conn, $level, 'channel'); }

Table of Contents

Methods

rollBack()  : void

Methods

rollBack()

public static rollBack(Connection $connection, int $entryLevel, string $logChannel) : void
Parameters
$connection : Connection
$entryLevel : int
$logChannel : string
On this page

Search results