inlm / dibi-transactions
Nested transactions for Dibi.
Fund package maintenance!
Other
Installs: 7 123
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.6.0
- dibi/dibi: >=3.0.0
Requires (Dev)
- nette/tester: ^2.0
- nette/utils: ^2.4 | ^3.0
- tracy/tracy: ^2.4
This package is auto-updated.
Last update: 2024-11-13 08:36:26 UTC
README
Nested transactions for Dibi.
Installation
Download a latest package or use Composer:
composer require inlm/dibi-transactions
Inlm\Dibi-transactions requires PHP 5.6.0 or later and Dibi.
Usage
$connection = new Dibi\Connection(); $transactions = new Inlm\DibiTransactions\Transactions($connection);
transactional()
$value = $transactions->transactional(function () use ($connection) { $connection->query('...'); $connection->query('...'); return $value; });
Transaction
$transaction = $transactions->createTransaction(); try { $connection->query('...'); $connection->query('...'); $transaction->commit(); } catch (Exception $e) { $transaction->rollback(); throw $e; }
Object Transaction
throws error if you forget to call commit()
or rollback()
. It can be connected with Tracy:
$transactions->onUnresolved[] = array(Inlm\DibiTransactions\Bridges\Tracy::class, 'logUnresolved');
begin
/ commit
/ rollback
try { $transactions->begin(); $connection->query('...'); $connection->query('...'); $transactions->commit(); } catch (Exception $e) { $transactions->rollback(); }
License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/