DBIx::TransactionManager - transaction handling for database.
basic usage:
use DBI; use DBIx::TransactionManager; my $dbh = DBI->connect('dbi:SQLite:'); my $tm = DBIx::TransactionManager->new($dbh); $tm->txn_begin; $dbh->do("insert into foo (id, var) values (1,'baz')"); $tm->txn_commit;
scope_gurad usage:
use DBI; use DBIx::TransactionManager; my $dbh = DBI->connect('dbi:SQLite:'); my $tm = DBIx::TransactionManager->new($dbh); my $txn = $tm->txn_scope; $dbh->do("insert into foo (id, var) values (1,'baz')"); $txn->commit;
nested transaction usage:
use DBI; use DBIx::TransactionManager; my $dbh = DBI->connect('dbi:SQLite:'); my $tm = DBIx::TransactionManager->new($dbh); { my $txn = $tm->txn_scope; $dbh->do("insert into foo (id, var) values (1,'baz')"); { my $txn2 = $tm->txn_scope; $dbh->do("insert into foo (id, var) values (2,'bab')"); $txn2->commit; } { my $txn3 = $tm->txn_scope; $dbh->do("insert into foo (id, var) values (3,'bee')"); $txn3->commit; } $txn->commit; }
DBIx::TransactionManager is a simple transaction manager. like DBIx::Class::Storage::TxnScopeGuard.
get DBIx::TransactionManager's instance object. $dbh parameter must be required.
get DBIx::TransactionManager::ScopeGuard's instance object.
see "DBIx::TransactionManager::ScopeGuard's METHODS"
Start the transaction.
Rollback the transaction.
Commit the transaction.
are you in transaction?
Atsushi Kobayashi <nekokak _at_ gmail _dot_ com>
DBIx::Class::Storage::TxnScopeGuard
DBIx::Skinny::Transaction
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install DBIx::TransactionManager, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::TransactionManager
CPAN shell
perl -MCPAN -e shell install DBIx::TransactionManager
For more information on module installation, please visit the detailed CPAN module installation guide.