本文整理汇总了C++中SqlStatementID类的典型用法代码示例。如果您正苦于以下问题:C++ SqlStatementID类的具体用法?C++ SqlStatementID怎么用?C++ SqlStatementID使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SqlStatementID类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateStatement
SqlStatement Database::CreateStatement(SqlStatementID& index, const char* fmt)
{
int nId = -1;
//check if statement ID is initialized
if (!index.initialized())
{
//convert to lower register
std::string szFmt(fmt);
//count input parameters
int nParams = std::count(szFmt.begin(), szFmt.end(), '?');
//find existing or add a new record in registry
LOCK_GUARD _guard(m_stmtGuard);
PreparedStmtRegistry::const_iterator iter = m_stmtRegistry.find(szFmt);
if (iter == m_stmtRegistry.end())
{
nId = ++m_iStmtIndex;
m_stmtRegistry[szFmt] = nId;
}
else
nId = iter->second;
//save initialized statement index info
index.init(nId, nParams);
}
return SqlStatement(index, *this);
}
示例2: DirectExecuteStmt
bool Database::DirectExecuteStmt(const SqlStatementID& id, SqlStmtParameters* params)
{
MANGOS_ASSERT(params);
std::auto_ptr<SqlStmtParameters> p(params);
//execute statement
SqlConnection::Lock _guard(getAsyncConnection());
return _guard->ExecuteStmt(id.ID(), *params);
}
示例3: if
unique_ptr<SqlStatement> ConcreteDatabase::makeStatement( SqlStatementID& index, std::string sqlText )
{
//initialize the statement if its not (or missing in the registry)
if(!index.isInitialized())
{
//count input parameters
size_t nParams = std::count(sqlText.begin(), sqlText.end(), '?');
UInt32 nId = _prepStmtRegistry.getStmtId(std::move(sqlText));
//save initialized statement index info
index.init(nId, nParams);
}
else if (!_prepStmtRegistry.idDefined(index.getId()))
_prepStmtRegistry.insertStmt(index.getId(),std::move(sqlText));
return unique_ptr<SqlStatement>(new SqlStatementImpl(index, *this));
}
示例4: ExecuteStmt
bool Database::ExecuteStmt(const SqlStatementID& id, SqlStmtParameters* params)
{
if (!m_pAsyncConn)
return false;
SqlTransaction* pTrans = m_TransStorage->get();
if (pTrans)
{
//add SQL request to trans queue
pTrans->DelayExecute(new SqlPreparedRequest(id.ID(), params));
}
else
{
//if async execution is not available
if (!m_bAllowAsyncTransactions)
return DirectExecuteStmt(id, params);
// Simple sql statement
m_threadBody->Delay(new SqlPreparedRequest(id.ID(), params));
}
return true;
}