lightools/transaction-nesting

Allows you to nest transactions with dibi database connection.

Maintainers

👁 janedbal

Package info

github.com/lightools/transaction-nesting

pkg:composer/lightools/transaction-nesting

Statistics

Installs: 14 141

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v1.0.1 2016-04-12 14:30 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 453ee5845ccc7d79a25b141cc18abca7e18578c5

This package is auto-updated.

Last update: 2026-06-10 21:50:33 UTC


README

This library allows you to nest database transactions over dibi connection.

Installation

$ composer require lightools/transaction-nesting

Simple usage

TransactionManager will begin/commit/rollback database transaction only if there is no other transaction running. So if you try to start new transaction when some transaction is active, it will not fail with error There is already an active transaction. This means you can nest transactions safely and TransactionManager will make sure that only the outer transaction will be performed.

$dibi = new Dibi\Connection($config);
$manager = new Lightools\TransactionNesting\TransactionManager($dibi);

$manager->transactional(function () {
 // your logic
});

Of course, this will break if you perform some query causing implicit commit (for example ALTER TABLE on MySQL).

How to run tests

$ vendor/bin/tester -c tests/php.ini -d extension_dir=ext tests