diff options
author | Machiavelli <none@none> | 2010-09-04 16:49:23 +0200 |
---|---|---|
committer | Machiavelli <none@none> | 2010-09-04 16:49:23 +0200 |
commit | 27c00a8cbbfb684630a8977ccd1b007d9e69d441 (patch) | |
tree | 9aa9200a0f8acce9707d9b3dfdfc011aefa5d3bc /src/server/shared/Database/Transaction.h | |
parent | fd1c6c54400bbfd117e689d5f9b6b0775b1a4272 (diff) |
Core/DBLayer:
- Allow transactions to contain both raw ad-hoc queries and prepared statement elements
* When coding on high level code, just make sure you use the right argument type for Transaction::Append and the proper execution will be done automagically
--HG--
branch : trunk
Diffstat (limited to 'src/server/shared/Database/Transaction.h')
-rw-r--r-- | src/server/shared/Database/Transaction.h | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/server/shared/Database/Transaction.h b/src/server/shared/Database/Transaction.h index 58c87b61270..cd749b0c2d7 100644 --- a/src/server/shared/Database/Transaction.h +++ b/src/server/shared/Database/Transaction.h @@ -21,6 +21,30 @@ #include "SQLOperation.h" +//- Forward declare (don't include header to prevent circular includes) +class PreparedStatement; + +//- Union that holds element data +union TransactionElementUnion +{ + PreparedStatement* stmt; + const char* query; +}; + +//- Type specifier of our element data +enum TransactionElementDataType +{ + TRANSACTION_ELEMENT_RAW, + TRANSACTION_ELEMENT_PREPARED, +}; + +//- The transaction element +struct TransactionElementData +{ + TransactionElementUnion element; + TransactionElementDataType type; +}; + /*! Transactions, high level class. */ class Transaction { @@ -28,6 +52,7 @@ class Transaction public: ~Transaction() { Cleanup(); } + void Append(PreparedStatement* statement); void Append(const char* sql); void PAppend(const char* sql, ...); @@ -35,7 +60,7 @@ class Transaction protected: void Cleanup(); - std::queue<char*> m_queries; + std::queue<TransactionElementData> m_queries; private: bool m_actioned; |