DBIx::TransactionManager::Extended - extended DBIx::TransactionManager
use DBI;
use DBIx::TransactionManager::Extended;
my $dbh = DBI->connect('dbi:SQLite:');
my $tm = DBIx::TransactionManager::Extended->new($dbh);
# begin transaction
$tm->txn_begin;
# execute query
$dbh->do("insert into foo (id, var) values (1,'baz')");
# And you can do multiple database operations here
for my $data (@data) {
push @{ $txn->context_data->{data} } => $data;
$tm->add_hook_after_commit(sub {
my $context_data = shift; # with the current (global) transaction
my @data = @{ $context_data->{data} };
return unless @data;
...
$context_data->{data} = [];
});
}
# and commit it.
$tm->txn_commit;
DBIx::TransactionManager::Extended is extended DBIx::TransactionManager. This module provides some useful methods for application development.
This is a accessor for a context data. The context data is a associative array about a current transaction's context data.
Adds hook that run at before the commit all transactions.
Adds hook that run at after the commit all transactions.
Removes hook that run at before the commit all transactions.
Removes hook that run at after the commit all transactions.
Copyright (C) karupanerura.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
karupanerura karupa@cpan.org