NAME

DBIx::Handler - fork-safe and easy transaction handling DBI handler

SYNOPSIS

use DBIx::Handler;
my $handler = DBIx::Handler->new($dsn, $user, $pass, $opts);
my $dbh = $handler->dbh;
$dbh->do(...);

DESCRIPTION

DBIx::Handler is fork-safe and easy transaction handling DBI handler.

DBIx::Hanler provide scope base transaction, fork safe dbh handling, simple.

METHODS

my $handler = DBIx::Handler->new($dsn, $user, $pass, $opts);

get database handling instance.

my $dbh = $handler->dbh;

get fork safe DBI handle.

$handler->disconnect;

disconnect current database handle.

my $txn_guard = $handler->txn_scope

Creates a new transaction scope guard object.

do {
    my $txn_guard = $handler->txn_scope;
        # some process
    $txn_guard->commit;
}

If an exception occurs, or the guard object otherwise leaves the scope before $txn->commit is called, the transaction will be rolled back by an explicit "txn_rollback" call. In essence this is akin to using a "txn_begin"/"txn_commit" pair, without having to worry about calling "txn_rollback" at the right places. Note that since there is no defined code closure, there will be no retries and other magic upon database disconnection.

$txn_manager = $handler->txn_manager

Get the DBIx::TransactionManager instance.

$handler->txn_begin

start new transaction.

$handler->txn_commit

commit transaction.

$handler->txn_rollback

rollback transaction.

$handler->txn_end

finish transaction.

$handler->in_txn

are you in transaction?

my @result = $handler->txn($coderef);

execute $coderef in auto transaction scope.

begin transaction before $coderef execute, do $coderef with database handle, after commit or rollback transaciont.

AUTHOR

Atsushi Kobayashi <nekokak _at_ gmail _dot_ com>

SEE ALSO

LICENSE

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

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 175:

'=item' outside of any '=over'

Around line 235:

You forgot a '=back' before '=head1'