DBIx::TransactionAllow transactions to be nested in DBI | |
Download |
DBIx::Transaction Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Tyler MacDonald
- Publisher web site:
- http://search.cpan.org/~crakrjack/
DBIx::Transaction Tags
DBIx::Transaction Description
Allow transactions to be nested in DBI DBIx::Transaction is a Perl wrapper around DBI that helps you manage your database transactions. It pays attention to nested transactions (having a begin_work/commit..rollback inside if another begin_work/commit..rollback) and the AutoCommit attribute of your database handle, making your code simpler and more resistant to different database drivers and options.SYNOPSIS use DBIx::Transaction; my $dbh = DBIx::Transaction->connect( 'DBI:mysql:database=foo', $user, $pass ); sub do_something { my($dbh, $num) = @_; return $dbh->transaction(sub { $dbh->do("DO SOMETHING IN SQL WHERE num = $num"); }); } my $good = 1; $dbh->begin_work; for my $i (1 .. 10) { $good = 0 unless do_something($dbh, $i); } if($good) { $dbh->commit; print "Every nested transaction worked and the database has been saved. "; } else { $dbh->rollback; print "A nested transaction rolled back, so nothing happened. "; } Requirements: · Perl
DBIx::Transaction Related Software