- add begin(), commit() and rollback() functions
authorAndreas Scherbaum <andreas@scherbaum.biz>
Fri, 8 Jun 2012 21:03:28 +0000 (23:03 +0200)
committerAndreas Scherbaum <andreas@scherbaum.biz>
Fri, 8 Jun 2012 21:03:28 +0000 (23:03 +0200)
db.pm

diff --git a/db.pm b/db.pm
index e29f38f425805fec54829306d703cf1fa3200636..10e307079b62bd961859595f22d4654299caad5a 100644 (file)
--- 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