本文整理汇总了C++中IDatabase::Close方法的典型用法代码示例。如果您正苦于以下问题:C++ IDatabase::Close方法的具体用法?C++ IDatabase::Close怎么用?C++ IDatabase::Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDatabase
的用法示例。
在下文中一共展示了IDatabase::Close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SQL_Connect
static cell_t SQL_Connect(IPluginContext *pContext, const cell_t *params)
{
char *conf, *err;
size_t maxlength = (size_t)params[4];
bool persistent = params[2] ? true : false;
pContext->LocalToString(params[1], &conf);
pContext->LocalToString(params[3], &err);
IDBDriver *driver;
IDatabase *db;
if (!g_DBMan.Connect(conf, &driver, &db, persistent, err, maxlength))
{
return BAD_HANDLE;
}
Handle_t hndl = g_DBMan.CreateHandle(DBHandle_Database, db, pContext->GetIdentity());
if (!hndl)
{
db->Close();
return BAD_HANDLE;
}
/* HACK! Add us to the dependency list */
CExtension *pExt = g_Extensions.GetExtensionFromIdent(driver->GetIdentity());
if (pExt)
{
g_Extensions.BindChildPlugin(pExt, g_PluginSys.GetPluginByCtx(pContext->GetContext()));
}
return hndl;
}
示例2: OnHandleDestroy
void DBManager::OnHandleDestroy(HandleType_t type, void *object)
{
if (type == m_DriverType)
{
/* Ignore */
return;
}
if (g_HandleSys.TypeCheck(type, m_DatabaseType))
{
IDatabase *pdb = (IDatabase *)object;
pdb->Close();
}
}
示例3: SQL_ConnectEx
static cell_t SQL_ConnectEx(IPluginContext *pContext, const cell_t *params)
{
IDBDriver *driver;
if (params[1] == BAD_HANDLE)
{
if ((driver = g_DBMan.GetDefaultDriver()) == NULL)
{
return pContext->ThrowNativeError("Could not find any default driver");
}
} else {
HandleError err;
if ((err = g_DBMan.ReadHandle(params[1], DBHandle_Driver, (void **)&driver))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid driver Handle %x (error: %d)", params[1], err);
}
}
char *host, *user, *pass, *database, *error;
size_t maxlength = (size_t)params[7];
bool persistent = params[8] ? true : false;
unsigned int port = params[9];
unsigned int maxTimeout = params[10];
pContext->LocalToString(params[2], &host);
pContext->LocalToString(params[3], &user);
pContext->LocalToString(params[4], &pass);
pContext->LocalToString(params[5], &database);
pContext->LocalToString(params[6], &error);
DatabaseInfo info;
info.database = database;
info.driver = driver->GetIdentifier();
info.host = host;
info.maxTimeout = maxTimeout;
info.pass = pass;
info.port = port;
info.user = user;
IDatabase *db = driver->Connect(&info, persistent, error, maxlength);
if (db)
{
Handle_t hndl = g_DBMan.CreateHandle(DBHandle_Database, db, pContext->GetIdentity());
if (!hndl)
{
db->Close();
return BAD_HANDLE;
}
/* HACK! Add us to the dependency list */
CExtension *pExt = g_Extensions.GetExtensionFromIdent(driver->GetIdentity());
if (pExt)
{
g_Extensions.BindChildPlugin(pExt, g_PluginSys.GetPluginByCtx(pContext->GetContext()));
}
return hndl;
}
return BAD_HANDLE;
}
示例4: SQL_ConnectCustom
static cell_t SQL_ConnectCustom(IPluginContext *pContext, const cell_t *params)
{
KeyValues *kv;
HandleError err;
kv = g_SourceMod.ReadKeyValuesHandle(params[1], &err, false);
if (kv == NULL)
{
return pContext->ThrowNativeError("Invalid KeyValues handle %x (error: %d)",
params[1],
err);
}
DatabaseInfo info;
info.database = kv->GetString("database", "");
info.driver = kv->GetString("driver", "default");
info.host = kv->GetString("host", "");
info.maxTimeout = kv->GetInt("timeout", 0);
info.pass = kv->GetString("pass", "");
info.port = kv->GetInt("port", 0);
info.user = kv->GetString("user", "");
IDBDriver *driver;
if (info.driver[0] == '\0' || strcmp(info.driver, "default") == 0)
{
driver = g_DBMan.GetDefaultDriver();
}
else
{
driver = g_DBMan.FindOrLoadDriver(info.driver);
}
if (driver == NULL)
{
char buffer[255];
UTIL_Format(buffer, sizeof(buffer), "Could not find driver \"%s\"", info.driver);
pContext->StringToLocalUTF8(params[2], params[3], buffer, NULL);
return BAD_HANDLE;
}
char *buffer;
IDatabase *db;
pContext->LocalToString(params[2], &buffer);
db = driver->Connect(&info, params[4] ? true : false, buffer, params[3]);
if (db == NULL)
{
return BAD_HANDLE;
}
Handle_t hndl = g_DBMan.CreateHandle(DBHandle_Database, db, pContext->GetIdentity());
if (!hndl)
{
db->Close();
return pContext->ThrowNativeError("Out of handles!");
}
/* HACK! Add us to the dependency list */
CExtension *pExt = g_Extensions.GetExtensionFromIdent(driver->GetIdentity());
if (pExt)
{
g_Extensions.BindChildPlugin(pExt, g_PluginSys.GetPluginByCtx(pContext->GetContext()));
}
return hndl;
}
示例5: SQL_ConnectCustom
static cell_t SQL_ConnectCustom(IPluginContext *pContext, const cell_t *params)
{
KeyValues *kv;
HandleError err;
kv = g_pSM->ReadKeyValuesHandle(params[1], &err, false);
if (kv == NULL)
{
return pContext->ThrowNativeError("Invalid KeyValues handle %x (error: %d)",
params[1],
err);
}
DatabaseInfo info = smcore.GetDBInfoFromKeyValues(kv);
IDBDriver *driver;
if (info.driver[0] == '\0' || strcmp(info.driver, "default") == 0)
{
driver = g_DBMan.GetDefaultDriver();
}
else
{
driver = g_DBMan.FindOrLoadDriver(info.driver);
}
if (driver == NULL)
{
char buffer[255];
g_pSM->Format(buffer, sizeof(buffer), "Could not find driver \"%s\"", info.driver);
pContext->StringToLocalUTF8(params[2], params[3], buffer, NULL);
return BAD_HANDLE;
}
char *buffer;
IDatabase *db;
pContext->LocalToString(params[2], &buffer);
db = driver->Connect(&info, params[4] ? true : false, buffer, params[3]);
if (db == NULL)
{
return BAD_HANDLE;
}
Handle_t hndl = g_DBMan.CreateHandle(DBHandle_Database, db, pContext->GetIdentity());
if (!hndl)
{
db->Close();
return pContext->ThrowNativeError("Out of handles!");
}
/* HACK! Add us to the dependency list */
IExtension *pExt = g_Extensions.GetExtensionFromIdent(driver->GetIdentity());
if (pExt)
{
g_Extensions.BindChildPlugin(pExt, scripts->FindPluginByContext(pContext->GetContext()));
}
return hndl;
}