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

Function SQL_Connect

core/logic/smn_database.cpp:400–431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

398};
399
400static cell_t SQL_Connect(IPluginContext *pContext, const cell_t *params)
401{
402 char *conf, *err;
403
404 size_t maxlength = (size_t)params[4];
405 bool persistent = params[2] ? true : false;
406 pContext->LocalToString(params[1], &conf);
407 pContext->LocalToString(params[3], &err);
408
409 IDBDriver *driver;
410 IDatabase *db;
411 if (!g_DBMan.Connect(conf, &driver, &db, persistent, err, maxlength))
412 {
413 return BAD_HANDLE;
414 }
415
416 Handle_t hndl = g_DBMan.CreateHandle(DBHandle_Database, db, pContext->GetIdentity());
417 if (!hndl)
418 {
419 db->Close();
420 return BAD_HANDLE;
421 }
422
423 /* HACK! Add us to the dependency list */
424 IExtension *pExt = g_Extensions.GetExtensionFromIdent(driver->GetIdentity());
425 if (pExt)
426 {
427 g_Extensions.BindChildPlugin(pExt, scripts->FindPluginByContext(pContext));
428 }
429
430 return hndl;
431}
432
433static cell_t ConnectToDbAsync(IPluginContext *pContext, const cell_t *params, AsyncCallbackMode acm)
434{

Callers

nothing calls this directly

Calls 7

GetExtensionFromIdentMethod · 0.80
BindChildPluginMethod · 0.80
ConnectMethod · 0.45
CreateHandleMethod · 0.45
GetIdentityMethod · 0.45
CloseMethod · 0.45
FindPluginByContextMethod · 0.45

Tested by

no test coverage detected