added SQL_CheckConfig() so sql admin plugins can default back
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401330
This commit is contained in:
@@ -38,7 +38,15 @@ public OnRebuildAdminCache(AdminCachePart:part)
|
||||
{
|
||||
/* First try to get a database connection */
|
||||
decl String:error[255];
|
||||
new Handle:db = SQL_Connect("default", true, error, sizeof(error));
|
||||
new Handle:db;
|
||||
|
||||
if (SQL_CheckConfig("admins"))
|
||||
{
|
||||
db = SQL_Connect("admins", true, error, sizeof(error));
|
||||
} else {
|
||||
db = SQL_Connect("default", true, error, sizeof(error));
|
||||
}
|
||||
|
||||
if (db == INVALID_HANDLE)
|
||||
{
|
||||
LogError("Could not connect to database \"default\": %s", error);
|
||||
|
||||
@@ -144,7 +144,12 @@ public OnDatabaseConnect(Handle:owner, Handle:hndl, const String:error[], any:da
|
||||
RequestDatabaseConnection()
|
||||
{
|
||||
ConnectLock = ++g_sequence;
|
||||
SQL_TConnect(OnDatabaseConnect, "default", ConnectLock);
|
||||
if (SQL_CheckConfig("admins"))
|
||||
{
|
||||
SQL_TConnect(OnDatabaseConnect, "admins", ConnectLock);
|
||||
} else {
|
||||
SQL_TConnect(OnDatabaseConnect, "default", ConnectLock);
|
||||
}
|
||||
}
|
||||
|
||||
public OnRebuildAdminCache(AdminCachePart:part)
|
||||
|
||||
@@ -131,6 +131,14 @@ native Handle:SQL_ConnectEx(Handle:driver,
|
||||
bool:persistent=true,
|
||||
port=0,
|
||||
maxTimeout=0);
|
||||
|
||||
/**
|
||||
* Returns if a named configuration is present in databases.cfg.
|
||||
*
|
||||
* @param name Configuration name.
|
||||
* @return True if it exists, false otherwise.
|
||||
*/
|
||||
native bool:SQL_CheckConfig(const String:name[]);
|
||||
|
||||
/**
|
||||
* Returns a driver Handle from a name string.
|
||||
|
||||
Reference in New Issue
Block a user