-
-
29 May 2014 04:19:59 UTC
- Distribution: DBIx-TransactionManager
- Module version: 1.13
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues (2)
- Testers (7300 / 2 / 0)
- Kwalitee
Bus factor: 1- 14.29% Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (24.25KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors- Atsushi Kobayashi <nekokak _at_ gmail _dot_ com>
- Dependencies
- DBI
- Try::Tiny
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
- NAME
- SYNOPSIS
- DESCRIPTION
- METHODS
- DBIx::TransactionManager::ScopeGuard's METHODS
- DBIx::TransactionManager and other transaction managers
- AUTHOR
- SEE ALSO
- LICENSE
NAME
DBIx::TransactionManager - Transaction handling for database.
SYNOPSIS
RAII style transaction management:
use DBI; use DBIx::TransactionManager; my $dbh = DBI->connect('dbi:SQLite:'); my $tm = DBIx::TransactionManager->new($dbh); # create transaction object my $txn = $tm->txn_scope; # execute query $dbh->do("insert into foo (id, var) values (1,'baz')"); # And you can do multiple database operations here # and commit it. $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; }
DESCRIPTION
DBIx::TransactionManager is a simple transaction manager. like DBIx::Class::Storage::TxnScopeGuard.
This module provides two futures.
If you are writing of DBIx::* or O/R Mapper, see DBIx::TransactionManager::Developers.
METHODS
- my $tm = DBIx::TransactionManager->new($dbh)
-
Creating an instance of this class.
$dbh
is required. - my $txn = $tm->txn_scope(%args)
-
Get DBIx::TransactionManager::ScopeGuard's instance object.
Options for this method is only for module creators, see DBIx::TransactionManager::Developers.
DBIx::TransactionManager::ScopeGuard's METHODS
- $txn->commit()
-
Commit the transaction.
If the
$tm
is in a nested transaction, TransactionManager doesn't do COMMIT at here. TM just poped transaction stack and do nothing. - $txn->rollback()
-
Rollback the transaction.
If the
$tm
is in a nested transaction, TransactionManager doesn't do ROLLBACK at here. TM just poped transaction stack and do nothing.
DBIx::TransactionManager and other transaction managers
You cannot use other transaction manager and DBIx::TransactionManager at once.
If you are using O/R mapper, you should use that's transaction management feature.
AUTHOR
Atsushi Kobayashi <nekokak _at_ gmail _dot_ com>
SEE ALSO
DBIx::Class::Storage::TxnScopeGuard
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install DBIx::TransactionManager, copy and paste the appropriate command in to your terminal.
cpanm DBIx::TransactionManager
perl -MCPAN -e shell install DBIx::TransactionManager
For more information on module installation, please visit the detailed CPAN module installation guide.