NAME

DBIx::TransactionManager::Extended::Txn - transaction object

SYNOPSIS

use DBI;
use DBIx::TransactionManager::Extended;

my $dbh = DBI->connect('dbi:SQLite:');
my $tm = DBIx::TransactionManager::Extended->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

    for my $data (@data) {
        push @{ $txn->context_data->{data} } => $data;
        $txn->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.
$txn->commit;

DESCRIPTION

This module provides shortcut for DBIx::TransactionManager::Extended and DBIx::TransactionManager::ScopeGuard.

EXTENDED METHODS

context_data

This is a accessor for a context data. The context data is a associative array about a current transaction's context data.

add_hook_before_commit

Adds hook that run at before the commit all transactions.

add_hook_after_commit

Adds hook that run at after the commit all transactions.

remove_hook_before_commit

Removes hook that run at before the commit all transactions.

remove_hook_after_commit

Removes hook that run at after the commit all transactions.

SEE ALSO

DBIx::TransactionManager

LICENSE

Copyright (C) karupanerura.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

karupanerura <karupa@cpan.org>