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

Function SQL_FetchString

core/logic/smn_database.cpp:1123–1163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1121}
1122
1123static cell_t SQL_FetchString(IPluginContext *pContext, const cell_t *params)
1124{
1125 IQuery *query;
1126 HandleError err;
1127
1128 if ((err = ReadQueryHndl(params[1], pContext, &query)) != HandleError_None)
1129 {
1130 return pContext->ThrowNativeError("Invalid query Handle %x (error: %d)", params[1], err);
1131 }
1132
1133 IResultSet *rs = query->GetResultSet();
1134 if (!rs)
1135 {
1136 return pContext->ThrowNativeError("No current result set");
1137 }
1138
1139 IResultRow *row = rs->CurrentRow();
1140 if (!row)
1141 {
1142 return pContext->ThrowNativeError("Current result set has no fetched rows");
1143 }
1144
1145 const char *str;
1146 size_t length;
1147 DBResult res = row->GetString(params[2], &str, &length);
1148
1149 if (res == DBVal_Error)
1150 {
1151 return pContext->ThrowNativeError("Error fetching data from field %d", params[2]);
1152 } else if (res == DBVal_TypeMismatch) {
1153 return pContext->ThrowNativeError("Could not fetch data in field %d as a string", params[2]);
1154 }
1155
1156 pContext->StringToLocalUTF8(params[3], params[4], str, &length);
1157
1158 cell_t *addr;
1159 pContext->LocalToPhysAddr(params[5], &addr);
1160 *addr = (cell_t)res;
1161
1162 return (cell_t)length;
1163}
1164
1165static cell_t SQL_FetchFloat(IPluginContext *pContext, const cell_t *params)
1166{

Callers

nothing calls this directly

Calls 4

ReadQueryHndlFunction · 0.85
GetResultSetMethod · 0.45
CurrentRowMethod · 0.45
GetStringMethod · 0.45

Tested by

no test coverage detected