$depth =
$this->connection->
transactionDepth();
$txn =
$this->connection->
startTransaction();
// Insert a single row into the testing table.
$this->connection->
insert('test'
) ->
fields([ 'name' => 'David' .
$suffix,
'age' => '24',
]) ->
execute();
$this->
assertTrue($this->connection->
inTransaction(), 'In transaction before calling nested transaction.'
);
// We're already in a transaction, but we call ->transactionInnerLayer
// to nest another transaction inside the current one.
$this->
transactionInnerLayer($suffix,
$rollback,
$ddl_statement);
$this->
assertTrue($this->connection->
inTransaction(), 'In transaction after calling nested transaction.'
);
if ($rollback) { // Roll back the transaction, if requested.
// This rollback should propagate to the last savepoint.
$txn->
rollBack();