当前位置: 首页>>代码示例>>C++>>正文


C++ IQuery::Execute2方法代码示例

本文整理汇总了C++中IQuery::Execute2方法的典型用法代码示例。如果您正苦于以下问题:C++ IQuery::Execute2方法的具体用法?C++ IQuery::Execute2怎么用?C++ IQuery::Execute2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IQuery的用法示例。


在下文中一共展示了IQuery::Execute2方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RunThread

void MysqlThread::RunThread(IThreadHandle *pHandle)
{
	DatabaseInfo info;

	info.database = m_db.chars();
	info.pass = "";
	info.user = "";
	info.host = "";
	info.port = 0;

	float save_time = m_qrInfo.queue_time;

	memset(&m_qrInfo, 0, sizeof(m_qrInfo));

	m_qrInfo.queue_time = save_time;

	IDatabase *pDatabase = g_Sqlite.Connect(&info, &m_qrInfo.amxinfo.info.errorcode, m_qrInfo.amxinfo.error, 254);
	IQuery *pQuery = NULL;
	if (!pDatabase)
	{
		m_qrInfo.connect_success = false;
		m_qrInfo.query_success = false;
	} else {
		m_qrInfo.connect_success = true;
		pQuery = pDatabase->PrepareQuery(m_query.chars());
		if (!pQuery->Execute2(&m_qrInfo.amxinfo.info, m_qrInfo.amxinfo.error, 254))
		{
			m_qrInfo.query_success = false;
		} else {
			m_qrInfo.query_success = true;
		}
	}

	if (m_qrInfo.query_success && m_qrInfo.amxinfo.info.rs)
	{
		m_atomicResult.CopyFrom(m_qrInfo.amxinfo.info.rs);
		m_qrInfo.amxinfo.info.rs = &m_atomicResult;
	}

	if (pQuery)
	{
		m_qrInfo.amxinfo.pQuery = pQuery;
	} else {
		m_qrInfo.amxinfo.opt_ptr = new char[m_query.length() + 1];
		strcpy(m_qrInfo.amxinfo.opt_ptr, m_query.chars());
	}

	if (pDatabase)
	{
		pDatabase->FreeHandle();
		pDatabase = NULL;
	}
}
开发者ID:Chuvi-w,项目名称:amxmodx,代码行数:53,代码来源:threading.cpp

示例2: MakeHandle

//native Result:dbi_query2(Sql:_sql, &rows, _query[], {Float,_}:...);
static cell AMX_NATIVE_CALL dbi_query2(AMX *amx, cell *params)
{
	olddb_s *old = (olddb_s *)GetHandle(params[1], Handle_OldDb);
	if (!old)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid DBI handle %d", params[1]);
		return -1;
	}

	int len;
	char *queryString = MF_FormatAmxString(amx, params, 3, &len);

	IQuery *pQuery = old->pDatabase->PrepareQuery(queryString);
	QueryInfo info;

	old->error[0] = '\0';
	old->errcode = 0;

	if (!pQuery->Execute2(&info, old->error, 254))
	{
		old->errcode = info.errorcode;
		return -1;
	} else {
		cell *addr = MF_GetAmxAddr(amx, params[2]);
		*addr = static_cast<cell>(info.affected_rows);
		if (info.rs && info.rs->RowCount())
		{
			oldresult_s *oldrs = new oldresult_s;
			int hndl;

			oldrs->info = info;
			oldrs->pQuery = pQuery;
			oldrs->firstCall = true;
			hndl = MakeHandle(oldrs, Handle_OldResult, FreeOldResult);
			return hndl;
		} else {
			pQuery->FreeHandle();
			return 0;
		}
	}

	/** never reach here */
	return 0;
}
开发者ID:9iky6,项目名称:amxmodx,代码行数:45,代码来源:oldcompat_sql.cpp


注:本文中的IQuery::Execute2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。