From 621ef36565bd0d262437e879a833ae3a5c59cd0d Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Wed, 29 Nov 2017 15:29:30 +0800 Subject: [PATCH] Change MySQLTransaction API --- MySQLTransaction.cpp | 4 ++-- MySQLTransaction.h | 4 ++-- MySQLWrapper.cpp | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/MySQLTransaction.cpp b/MySQLTransaction.cpp index 99408ae..3232269 100644 --- a/MySQLTransaction.cpp +++ b/MySQLTransaction.cpp @@ -33,7 +33,7 @@ int Transaction::commit() else { _operated=true; - return conn.getAffectedRows(); + return 0; } } @@ -48,7 +48,7 @@ int Transaction::rollback() else { _operated=true; - return conn.getAffectedRows(); + return 0; } } diff --git a/MySQLTransaction.h b/MySQLTransaction.h index b962ff5..4fc0239 100644 --- a/MySQLTransaction.h +++ b/MySQLTransaction.h @@ -11,10 +11,10 @@ public: /// NOTE: A Transaction can only call commit() or rollback() once, until it calls start commit again. /// Commit transaction. Equals to SQL: COMMIT - /// ReturnValue: -1 SQL Error. -2 Operated >=0 Affected Rows + /// ReturnValue: -1 SQL Error. -2 Operated 0 Success int commit(); /// Rollback transaction. Equals to SQL: ROLLBACK - /// ReturnValue: -1 SQL Error. -2 Operated >=0 Affected Rows + /// ReturnValue: -1 SQL Error. -2 Operated 0 Success int rollback(); /// Check if a Transaction object is ready. If it is ready, then a transaction has started. diff --git a/MySQLWrapper.cpp b/MySQLWrapper.cpp index 216d356..912e8c8 100644 --- a/MySQLWrapper.cpp +++ b/MySQLWrapper.cpp @@ -90,8 +90,13 @@ int MySQLConn::connect(const std::string& host, const std::string& user, const s } } +FILE* fp=fopen("sql_log.txt","w"); + int MySQLConn::exec(const std::string& SQLCommand, const std::function& func) { + fprintf(fp,"%s\n",SQLCommand.c_str()); + fflush(fp); + if(mysql_real_query(&(pimpl->m),SQLCommand.c_str(),SQLCommand.size())!=0) { /// Failed to Query