MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / SQL_FetchInt

Function SQL_FetchInt

core/logic/smn_database.cpp:1204–1241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1202}
1203
1204static cell_t SQL_FetchInt(IPluginContext *pContext, const cell_t *params)
1205{
1206 IQuery *query;
1207 HandleError err;
1208
1209 if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
1210 {
1211 return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
1212 }
1213
1214 IResultSet *rs = query->GetResultSet();
1215 if (!rs)
1216 {
1217 return pContext->ThrowNativeError("No current result set");
1218 }
1219
1220 IResultRow *row = rs->CurrentRow();
1221 if (!row)
1222 {
1223 return pContext->ThrowNativeError("Current result set has no fetched rows");
1224 }
1225
1226 int iv;
1227 DBResult res = row->GetInt(params[2], &iv);
1228
1229 if (res == DBVal_Error)
1230 {
1231 return pContext->ThrowNativeError("Error fetching data from field %d", params[2]);
1232 } else if (res == DBVal_TypeMismatch) {
1233 return pContext->ThrowNativeError("Could not fetch data in field %d as an integer", params[2]);
1234 }
1235
1236 cell_t *addr;
1237 pContext->LocalToPhysAddr(params[3], &addr);
1238 *addr = (cell_t)res;
1239
1240 return iv;
1241}
1242
1243static cell_t SQL_IsFieldNull(IPluginContext *pContext, const cell_t *params)
1244{

Callers

nothing calls this directly

Calls 4

ReadQueryHndlFunction · 0.85
GetResultSetMethod · 0.45
CurrentRowMethod · 0.45
GetIntMethod · 0.45

Tested by

no test coverage detected