27 lines
838 B
C++
27 lines
838 B
C++
#include "MySQLWrapper.h"
|
|
|
|
class Transaction
|
|
{
|
|
public:
|
|
/// Start Transaction on construct.
|
|
Transaction(MySQLConn& MySQLConnection);
|
|
|
|
/// Rollback transaction on destruct. If commit() or rollback() is called, this function will not execute any sql.
|
|
~Transaction();
|
|
|
|
/// 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 Success
|
|
int commit();
|
|
/// Rollback transaction. Equals to SQL: ROLLBACK
|
|
/// 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.
|
|
bool isReady() const;
|
|
private:
|
|
MySQLConn& conn;
|
|
bool _isReady;
|
|
bool _operated;
|
|
};
|