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


C++ IResultSet::GetRow方法代码示例

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


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

示例1: sizeof

static cell AMX_NATIVE_CALL SQL_ReadResult(AMX *amx, cell *params)
{
	AmxQueryInfo *qInfo = (AmxQueryInfo *)GetHandle(params[1], Handle_Query);
	if (!qInfo)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid query handle: %d", params[1]);
		return 0;
	}

	IResultSet *rs = qInfo->info.rs;

	if (!rs || rs->IsDone())
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "No result set in this query!");
		return 0;
	}

	IResultRow *row = rs->GetRow();

	unsigned int col = static_cast<unsigned int>(params[2]);
	if (col >= rs->FieldCount())
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid column: %d", col);
		return 0;
	}

	cell numparams = params[0] / sizeof(cell);
	switch (numparams)
	{
	case 4:
		{
			const char *str = row->GetString(col);
			if (!str)
				str = "";
			cell *len = MF_GetAmxAddr(amx, params[4]);
			MF_SetAmxString(amx, params[3], str, (int)*len);
			break;
		}
	case 3:
		{
			REAL num = row->GetFloat(col);
			cell *addr = MF_GetAmxAddr(amx, params[3]);
			*addr = amx_ftoc(num);
			break;
		}
	case 2:
		{
			int num = row->GetInt(col);
			return num;
			break;
		}
	default:
		{
			MF_LogError(amx, AMX_ERR_NATIVE, "Bad number of arguments passed.");
			break;
		}
	}

	return 1;
}
开发者ID:Arkshine,项目名称:amxmodx,代码行数:60,代码来源:basic_sql.cpp

示例2:

static cell AMX_NATIVE_CALL SQL_IsNull(AMX *amx, cell *params)
{
	AmxQueryInfo *qInfo = (AmxQueryInfo *)GetHandle(params[1], Handle_Query);
	if (!qInfo)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid query handle: %d", params[1]);
		return 0;
	}

	IResultSet *rs = qInfo->info.rs;

	if (!rs || rs->IsDone())
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "No result set in this query!");
		return 0;
	}

	unsigned int col = static_cast<unsigned int>(params[2]);
	if (col >= rs->FieldCount())
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid column: %d", col);
		return 0;
	}

	IResultRow *rr = rs->GetRow();

	return rr->IsNull(col) ? 1 : 0;
}
开发者ID:Arkshine,项目名称:amxmodx,代码行数:28,代码来源:basic_sql.cpp

示例3: atoi

//native dbi_field(Result:_result, _fieldnum, {Float,_}:... );
static cell AMX_NATIVE_CALL dbi_field(AMX *amx, cell *params)
{
	oldresult_s *oldrs = (oldresult_s *)GetHandle(params[1], Handle_OldResult);
	if (!oldrs)
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid DBI result handle %d", params[1]);
		return 0;
	}

	IResultSet *rs = oldrs->info.rs;
	if (rs->IsDone())
	{
		return 0;
	}
	IResultRow *rr = rs->GetRow();
	unsigned int num = (unsigned int)params[2] - 1;
	if (num >= rs->FieldCount())
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Invalid column %d", params[2]);
		return 0;
	}

	cell stype = params[0] / sizeof(cell);
	const char *data = rr->GetString(num);
	if (!data)
		data = "";

	switch (stype)
	{
	case 2:
		{
			return atoi(data);
			break;
		}
	case 3:
		{
			cell *destaddr = MF_GetAmxAddr(amx, params[3]);
			REAL fdata = atof(data);
			*destaddr = amx_ftoc(fdata);
			return 1;
			break;
		}
	case 4:
		{
			return MF_SetAmxString(amx, params[3], data, params[4]);
			break;
		}
	}

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


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