本文整理汇总了C++中SqlStmtParameters类的典型用法代码示例。如果您正苦于以下问题:C++ SqlStmtParameters类的具体用法?C++ SqlStmtParameters怎么用?C++ SqlStmtParameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SqlStmtParameters类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MANGOS_ASSERT
void SqlPlainPreparedStatement::bind( const SqlStmtParameters& holder )
{
//verify if we bound all needed input parameters
if(m_nParams != holder.boundParams())
{
MANGOS_ASSERT(false);
return;
}
//reset resulting plain SQL request
m_szPlainRequest = m_szFmt;
size_t nLastPos = 0;
SqlStmtParameters::ParameterContainer const& _args = holder.params();
SqlStmtParameters::ParameterContainer::const_iterator iter_last = _args.end();
for (SqlStmtParameters::ParameterContainer::const_iterator iter = _args.begin(); iter != iter_last; ++iter)
{
//bind parameter
const SqlStmtFieldData& data = (*iter);
std::ostringstream fmt;
DataToString(data, fmt);
nLastPos = m_szPlainRequest.find('?', nLastPos);
if(nLastPos != std::string::npos)
{
std::string tmp = fmt.str();
m_szPlainRequest.replace(nLastPos, 1, tmp);
nLastPos += tmp.length();
}
}
}
示例2: poco_assert
void MySqlPreparedStatement::bind( const SqlStmtParameters& holder )
{
poco_assert(isPrepared());
poco_assert(_myArgs.size() == _numParams);
//finalize adding params
if (_myArgs.size() < 1)
return;
//verify if we bound all needed input parameters
if(_numParams != holder.boundParams())
{
poco_bugcheck_msg("Not all parameters bound in MySqlPreparedStatement");
return;
}
size_t nIndex = 0;
const SqlStmtParameters::ParameterContainer& holderArgs = holder.params();
for (auto it = holderArgs.begin(); it!=holderArgs.end(); ++it)
{
//bind parameter
addParam(nIndex++, (*it));
}
//bind input arguments
if(mysql_stmt_bind_param(_myStmt, &_myArgs[0]))
poco_bugcheck_msg((string("mysql_stmt_bind_param() failed with ERROR ")+mysql_stmt_error(_myStmt)).c_str());
}
示例3: detach
bool SqlStatement::DirectExecute()
{
SqlStmtParameters * args = detach();
//verify amount of bound parameters
if(args->boundParams() != arguments())
{
sLog.outError("SQL ERROR: wrong amount of parameters (%i instead of %i)", args->boundParams(), arguments());
sLog.outError("SQL ERROR: statement: %s", m_pDB->GetStmtString(ID()).c_str());
MANGOS_ASSERT(false);
return false;
}
return m_pDB->DirectExecuteStmt(m_index, args);
}
示例4: MANGOS_ASSERT
void MySqlPreparedStatement::bind( const SqlStmtParameters& holder )
{
if(!isPrepared())
{
MANGOS_ASSERT(false);
return;
}
//finalize adding params
if(!m_pInputArgs)
return;
//verify if we bound all needed input parameters
if(m_nParams != holder.boundParams())
{
MANGOS_ASSERT(false);
return;
}
int nIndex = 0;
SqlStmtParameters::ParameterContainer const& _args = holder.params();
SqlStmtParameters::ParameterContainer::const_iterator iter_last = _args.end();
for (SqlStmtParameters::ParameterContainer::const_iterator iter = _args.begin(); iter != iter_last; ++iter)
{
//bind parameter
addParam(nIndex++, (*iter));
}
//bind input arguments
if(mysql_stmt_bind_param(m_stmt, m_pInputArgs))
{
sLog.outError("SQL ERROR: mysql_stmt_bind_param() failed\n");
sLog.outError("SQL ERROR: %s", mysql_stmt_error(m_stmt));
}
}