added no_transaction
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 16 Oct 2010 17:40:56 +0000 (17:40 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 16 Oct 2010 17:40:56 +0000 (17:40 +0000)
git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@1344 07558da8-63fa-0310-ba24-9fe276d99e06

lib/WebPAC/Output/DBI.pm

index 5295699..7016060 100644 (file)
@@ -14,6 +14,8 @@ __PACKAGE__->mk_accessors(qw(
        schema
 
        table
+
+       no_transaction
 ));
 
 use Data::Dump qw/dump/;
@@ -42,7 +44,7 @@ sub init {
 
        $self->{_dbh} = DBI->connect( $self->dsn, $self->user, $self->passwd, { RaiseError => 1 } );
 
-       $self->{_dbh}->begin_work;
+       $self->{_dbh}->begin_work unless $self->no_transaction;
 
        if ( -e $self->schema ) {
                foreach my $sql ( split(/;/, scalar read_file( $self->schema )) ) {
@@ -128,9 +130,10 @@ sub finish {
 
        $log->info('finish');
 
-       $self->{_dbh}->commit;
-       
-       $log->info('commit done');
+       unless ( $self->no_transaction ) {
+               $self->{_dbh}->commit;
+               $log->info('commit done');
+       }
 
        return 1;
 }