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

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

DBIx::Handler is fork-safe and easy transaction handling DBI handler.
DBIx::Hanler provide scope base transaction, fork safe dbh handling, simple.

get database handling instance.
connect method is new methos alias.
get fork safe DBI handle.
disconnect current database handle.
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.
Get the DBIx::TransactionManager instance.
start new transaction.
commit transaction.
rollback transaction.
are you in transaction?
execute $coderef in auto transaction scope.
begin transaction before $coderef execute, do $coderef with database handle, after commit or rollback transaciont.
$handler->txn(sub {
my $dbh = shift;
$dbh->do(...);
});
equals to:
$handler->txn_begin;
my $dbh = $handler->dbh;
$dbh->do(...);
$handler->txn_rollback;
exexute $coderef.
my $rs = $handler->run(sub {
my $dbh = shift;
$dbh->selectall_arrayref(...);
});
or
my @result = $handler->run(sub {
my $dbh = shift;
$dbh->selectrow_array('...');
});
exexute query. return database statement handler.
set result_class package name.
this result_class use to be create query method response object.
inject sql comment when trace_query is true.

Atsushi Kobayashi <nekokak _at_ gmail _dot_ com>


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