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


C++ IQuery类代码示例

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


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

示例1: SQL_FieldNumToName

static cell_t SQL_FieldNumToName(IPluginContext *pContext, const cell_t *params)
{
	IQuery *query;
	HandleError err;

	if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
	}

	IResultSet *rs = query->GetResultSet();
	if (!rs)
	{
		return pContext->ThrowNativeError("No current result set");
	}

	unsigned int field = params[2];

	const char *fldname;
	if ((fldname = rs->FieldNumToName(field)) == NULL)
	{
		return pContext->ThrowNativeError("Invalid field index %d", field);
	}

	pContext->StringToLocalUTF8(params[3], params[4], fldname, NULL);

	return 1;
}
开发者ID:pmrowla,项目名称:sourcemod-1.5,代码行数:28,代码来源:smn_database.cpp

示例2: SQL_FetchSize

static cell_t SQL_FetchSize(IPluginContext *pContext, const cell_t *params)
{
	IQuery *query;
	HandleError err;

	if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
	}

	IResultSet *rs = query->GetResultSet();
	if (!rs)
	{
		return pContext->ThrowNativeError("No current result set");
	}

	IResultRow *row = rs->CurrentRow();
	if (!row)
	{
		return pContext->ThrowNativeError("Current result set has no fetched rows");
	}

	if ((unsigned)params[2] >= rs->GetFieldCount())
	{
		return pContext->ThrowNativeError("Invalid field index %d", params[2]);
	}

	return row->GetDataSize(params[2]);
}
开发者ID:pmrowla,项目名称:sourcemod-1.5,代码行数:29,代码来源:smn_database.cpp

示例3: DoQueryEx

bool MyDatabase::DoSimpleQueryEx(const char *query, size_t len)
{
	IQuery *pQuery = DoQueryEx(query, len);
	if (!pQuery)
	{
		return false;
	}
	pQuery->Destroy();
	return true;
}
开发者ID:asceth,项目名称:synapi,代码行数:10,代码来源:MyDatabase.cpp

示例4: DoQuery

bool MyDatabase::DoSimpleQuery(const char *query)
{
	IQuery *pQuery = DoQuery(query);
	if (!pQuery)
	{
		return false;
	}
	pQuery->Destroy();
	return true;
}
开发者ID:asceth,项目名称:synapi,代码行数:10,代码来源:MyDatabase.cpp

示例5: SQL_HasResultSet

static cell_t SQL_HasResultSet(IPluginContext *pContext, const cell_t *params)
{
	IQuery *query;
	HandleError err;

	if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
	}

	return query->GetResultSet() != NULL ? true : false;
}
开发者ID:pmrowla,项目名称:sourcemod-1.5,代码行数:12,代码来源:smn_database.cpp

示例6: SQL_FetchMoreResults

static cell_t SQL_FetchMoreResults(IPluginContext *pContext, const cell_t *params)
{
	IQuery *query;
	HandleError err;

	if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
	}

	return query->FetchMoreResults() ? 1 : 0;
}
开发者ID:pmrowla,项目名称:sourcemod-1.5,代码行数:12,代码来源:smn_database.cpp

示例7: memset

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

示例8: SQL_FetchRow

static cell_t SQL_FetchRow(IPluginContext *pContext, const cell_t *params)
{
	IQuery *query;
	HandleError err;

	if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
	}

	IResultSet *rs = query->GetResultSet();
	if (!rs)
	{
		return pContext->ThrowNativeError("No current result set");
	}

	return (rs->FetchRow() != NULL) ? true : false;
}
开发者ID:pmrowla,项目名称:sourcemod-1.5,代码行数:18,代码来源:smn_database.cpp

示例9: SQL_GetFieldCount

static cell_t SQL_GetFieldCount(IPluginContext *pContext, const cell_t *params)
{
	IQuery *query;
	HandleError err;

	if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
	}

	IResultSet *rs = query->GetResultSet();
	if (!rs)
	{
		return 0;
	}

	return rs->GetFieldCount();
}
开发者ID:pmrowla,项目名称:sourcemod-1.5,代码行数:18,代码来源:smn_database.cpp

示例10: dbi_query2

//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

示例11: SQL_Query

static cell_t SQL_Query(IPluginContext *pContext, const cell_t *params)
{
	IDatabase *db = NULL;
	HandleError err;

	if ((err = g_DBMan.ReadHandle(params[1], DBHandle_Database, (void **)&db))
		!= HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid database Handle %x (error: %d)", params[1], err);
	}

	char *query;
	pContext->LocalToString(params[2], &query);

	IQuery *qr;
	
	if (params[0] >= 3 && params[3] != -1)
	{
		qr = db->DoQueryEx(query, params[3]);
	}
	else
	{
		qr = db->DoQuery(query);
	}

	if (!qr)
	{
		return BAD_HANDLE;
	}

	CombinedQuery *c = new CombinedQuery;
	c->query = qr;
	c->db = db;
	Handle_t hndl = g_HandleSys.CreateHandle(hCombinedQueryType, c, pContext->GetIdentity(), g_pCoreIdent, NULL);
	if (hndl == BAD_HANDLE)
	{
		qr->Destroy();
		delete c;
		return BAD_HANDLE;
	}

	return hndl;
}
开发者ID:pmrowla,项目名称:sourcemod-1.5,代码行数:43,代码来源:smn_database.cpp

示例12: SQL_FetchString

static cell_t SQL_FetchString(IPluginContext *pContext, const cell_t *params)
{
	IQuery *query;
	HandleError err;

	if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
	}

	IResultSet *rs = query->GetResultSet();
	if (!rs)
	{
		return pContext->ThrowNativeError("No current result set");
	}

	IResultRow *row = rs->CurrentRow();
	if (!row)
	{
		return pContext->ThrowNativeError("Current result set has no fetched rows");
	}

	const char *str;
	size_t length;
	DBResult res = row->GetString(params[2], &str, &length);

	if (res == DBVal_Error)
	{
		return pContext->ThrowNativeError("Error fetching data from field %d", params[2]);
	} else if (res == DBVal_TypeMismatch) {
		return pContext->ThrowNativeError("Could not fetch data in field %d as a string", params[2]);
	}

	pContext->StringToLocalUTF8(params[3], params[4], str, &length);

	cell_t *addr;
	pContext->LocalToPhysAddr(params[5], &addr);
	*addr = (cell_t)res;

	return (cell_t)length;
}
开发者ID:pmrowla,项目名称:sourcemod-1.5,代码行数:41,代码来源:smn_database.cpp

示例13: SQL_FetchInt

static cell_t SQL_FetchInt(IPluginContext *pContext, const cell_t *params)
{
	IQuery *query;
	HandleError err;

	if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
	}

	IResultSet *rs = query->GetResultSet();
	if (!rs)
	{
		return pContext->ThrowNativeError("No current result set");
	}

	IResultRow *row = rs->CurrentRow();
	if (!row)
	{
		return pContext->ThrowNativeError("Current result set has no fetched rows");
	}

	int iv;
	DBResult res = row->GetInt(params[2], &iv);

	if (res == DBVal_Error)
	{
		return pContext->ThrowNativeError("Error fetching data from field %d", params[2]);
	} else if (res == DBVal_TypeMismatch) {
		return pContext->ThrowNativeError("Could not fetch data in field %d as an integer", params[2]);
	}

	cell_t *addr;
	pContext->LocalToPhysAddr(params[3], &addr);
	*addr = (cell_t)res;

	return iv;
}
开发者ID:pmrowla,项目名称:sourcemod-1.5,代码行数:38,代码来源:smn_database.cpp

示例14: SQL_FieldNameToNum

static cell_t SQL_FieldNameToNum(IPluginContext *pContext, const cell_t *params)
{
	IQuery *query;
	HandleError err;

	if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
	}

	IResultSet *rs = query->GetResultSet();
	if (!rs)
	{
		return pContext->ThrowNativeError("No current result set");
	}

	char *field;
	pContext->LocalToString(params[2], &field);

	cell_t *num;
	pContext->LocalToPhysAddr(params[3], &num);

	return rs->FieldNameToNum(field, (unsigned int *)num) ? 1 : 0;
}
开发者ID:pmrowla,项目名称:sourcemod-1.5,代码行数:24,代码来源:smn_database.cpp


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