Core/DBLayer: Implement global ExecuteOrAppend methods to DatabaseWorkerPool for executing queries in a diverse context (transaction or non transaction) - instead of local to Guild.cpp

--HG--
branch : trunk
This commit is contained in:
Machiavelli
2010-12-13 16:27:14 +01:00
parent 426b28e344
commit 976225a9dd
2 changed files with 29 additions and 17 deletions

View File

@@ -270,6 +270,26 @@ class DatabaseWorkerPool
Enqueue(new TransactionTask(transaction));
}
//! Method used to execute prepared statements in a diverse context.
//! Will be wrapped in a transaction if valid object is present, otherwise executed standalone.
void ExecuteOrAppend(SQLTransaction& trans, PreparedStatement* stmt)
{
if (trans.null())
Execute(stmt);
else
trans->Append(stmt);
}
//! Method used to execute ad-hoc statements in a diverse context.
//! Will be wrapped in a transaction if valid object is present, otherwise executed standalone.
void ExecuteOrAppend(SQLTransaction& trans, const char* sql)
{
if (trans.null())
Execute(stmt);
else
trans->Append(sql);
}
PreparedStatement* GetPreparedStatement(uint32 index)
{
return new PreparedStatement(index);