GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
DBIx::TransactionManager(3) User Contributed Perl Documentation DBIx::TransactionManager(3)

DBIx::TransactionManager - Transaction handling for database.

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

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

This module provides two futures.

RAII based transaction management
Nested transaction management

If you are writing of DBIx::* or O/R Mapper, see DBIx::TransactionManager::Developers.

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.

$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.

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.

Atsushi Kobayashi <nekokak _at_ gmail _dot_ com>

DBIx::Class::Storage::TxnScopeGuard

DBIx::Skinny::Transaction

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2014-05-29 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.