The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

DBIx::TransactionManager - transaction handling for database.

SYNOPSIS

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;
    }
    

DESCRIPTION

DBIx::TransactionManager is a simple transaction manager. like DBIx::Class::Storage::TxnScopeGuard.

METHODS

my $tm = DBIx::TransactionManager->new($dbh)

get DBIx::TransactionManager's instance object. $dbh parameter must be required.

my $txn = $tm->txn_scope

get DBIx::TransactionManager::ScopeGuard's instance object.

see "DBIx::TransactionManager::ScopeGuard's METHODS"

$tm->txn_begin

Start the transaction.

$tm->txn_rollback

Rollback the transaction.

$tm->txn_commit

Commit the transaction.

DBIx::TransactionManager::ScopeGuard's METHODS

$txn->commit

Commit the transaction.

$txn->rollback

Rollback the transaction.

$txn->in_transaction

are you in transaction?

AUTHOR

Atsushi Kobayashi <nekokak _at_ gmail _dot_ com>

SEE ALSO

DBIx::Class::Storage::TxnScopeGuard

DBIx::Skinny::Transaction

LICENSE

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