From 57b2d03221438b13a06af7b7927ba0c7f81e6175 Mon Sep 17 00:00:00 2001 From: Andreas Scherbaum Date: Fri, 8 Jun 2012 23:03:28 +0200 Subject: [PATCH] - add begin(), commit() and rollback() functions --- db.pm | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/db.pm b/db.pm index e29f38f..10e3070 100644 --- a/db.pm +++ b/db.pm @@ -268,7 +268,7 @@ sub do { my $result = $self->{db_connection}->do($query); if (!$result) { - main::print_msg("Could not execute database query", ERROR); + main::print_msg("Could not execute database query: $DBI::errstr", ERROR); return 0; } $main::statistics{'database_queries'}++; @@ -303,7 +303,7 @@ sub query { my $st = $self->{db_connection}->prepare($query); if (!$st->execute(@param)) { - main::print_msg("Could not execute database query", ERROR); + main::print_msg("Could not execute database query: $DBI::errstr", ERROR); return undef; } $main::statistics{'database_queries'}++; @@ -312,6 +312,51 @@ sub query { } +# begin() +# +# start a stransaction +# +# parameter: +# - self +# return: +# - status of the command +sub begin { + my $self = shift; + + return $self->{db_connection}->begin_work(); +} + + +# commit() +# +# commit a stransaction +# +# parameter: +# - self +# return: +# - status of the command +sub commit { + my $self = shift; + + return $self->{db_connection}->commit(); +} + + +# rollback() +# +# rollback a stransaction +# +# parameter: +# - self +# return: +# - status of the command +sub rollback { + my $self = shift; + + return $self->{db_connection}->rollback(); +} + + # DESTROY() # # destructor -- 2.39.5