| 398 | }; |
| 399 | |
| 400 | static 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 | |
| 433 | static cell_t ConnectToDbAsync(IPluginContext *pContext, const cell_t *params, AsyncCallbackMode acm) |
| 434 | { |
nothing calls this directly
no test coverage detected