#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 Affected Rows int commit(); /// Rollback transaction. Equals to SQL: ROLLBACK /// ReturnValue: -1 SQL Error. -2 Operated >=0 Affected Rows 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; };