summaryrefslogtreecommitdiff
path: root/lib/input
diff options
context:
space:
mode:
Diffstat (limited to 'lib/input')
-rw-r--r--lib/input/mysqlConn.cpp20
-rw-r--r--lib/input/mysqlConn.h4
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/input/mysqlConn.cpp b/lib/input/mysqlConn.cpp
index 362f9ea..99c2891 100644
--- a/lib/input/mysqlConn.cpp
+++ b/lib/input/mysqlConn.cpp
@@ -52,4 +52,24 @@ namespace MyGrate::Input {
{
return std::make_unique<MySQLPrepStmt>(q, this);
}
+
+ void
+ MySQLConn::beginTx()
+ {
+ verify<MySQLErr>(!mysql_autocommit(this, false), "Auto commit off", this);
+ }
+
+ void
+ MySQLConn::commitTx()
+ {
+ verify<MySQLErr>(!mysql_commit(this), "Commit", this);
+ verify<MySQLErr>(!mysql_autocommit(this, true), "Auto commit on", this);
+ }
+
+ void
+ MySQLConn::rollbackTx()
+ {
+ verify<MySQLErr>(!mysql_rollback(this), "Rollback", this);
+ verify<MySQLErr>(!mysql_autocommit(this, true), "Auto commit on", this);
+ }
}
diff --git a/lib/input/mysqlConn.h b/lib/input/mysqlConn.h
index dfb408f..bd53616 100644
--- a/lib/input/mysqlConn.h
+++ b/lib/input/mysqlConn.h
@@ -29,6 +29,10 @@ namespace MyGrate::Input {
void query(const char * const q, const std::initializer_list<DbValue> &) override;
DbPrepStmtPtr prepare(const char * const, std::size_t) override;
+
+ void beginTx() override;
+ void commitTx() override;
+ void rollbackTx() override;
};
}