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
This commit is contained in:
1 parent
fd1c6c5440
commit
27c00a8cbb
2 files changed
+79
-17
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user