Change MySQLTransaction API
This commit is contained in:
parent
cceb695515
commit
621ef36565
|
@ -33,7 +33,7 @@ int Transaction::commit()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_operated=true;
|
_operated=true;
|
||||||
return conn.getAffectedRows();
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ int Transaction::rollback()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_operated=true;
|
_operated=true;
|
||||||
return conn.getAffectedRows();
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,10 @@ public:
|
||||||
|
|
||||||
/// NOTE: A Transaction can only call commit() or rollback() once, until it calls start commit again.
|
/// NOTE: A Transaction can only call commit() or rollback() once, until it calls start commit again.
|
||||||
/// Commit transaction. Equals to SQL: COMMIT
|
/// 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();
|
int commit();
|
||||||
/// Rollback transaction. Equals to SQL: ROLLBACK
|
/// 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();
|
int rollback();
|
||||||
|
|
||||||
/// Check if a Transaction object is ready. If it is ready, then a transaction has started.
|
/// Check if a Transaction object is ready. If it is ready, then a transaction has started.
|
||||||
|
|
|
@ -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)
|
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)
|
if(mysql_real_query(&(pimpl->m),SQLCommand.c_str(),SQLCommand.size())!=0)
|
||||||
{
|
{
|
||||||
/// Failed to Query
|
/// Failed to Query
|
||||||
|
|
Loading…
Reference in New Issue
Block a user