Change MySQLTransaction API

This commit is contained in:
Kirigaya Kazuto 2017-11-29 15:29:30 +08:00
parent cceb695515
commit 621ef36565
3 changed files with 9 additions and 4 deletions

View File

@ -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;
}
}

View File

@ -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.

View File

@ -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<void(MySQLResult&)>& 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