- i->second->SetEnable(true);
- if (!i->second->Connect())
- {
- /* XXX: MUTEX */
- pthread_mutex_lock(&logging_mutex);
- ServerInstance->Log(DEFAULT,"SQL: Failed to connect database "+i->second->GetHost()+": Error: "+i->second->GetError());
- i->second->SetEnable(false);
- pthread_mutex_unlock(&logging_mutex);
- }
- }
-}
-
-void LoadDatabases(ConfigReader* ThisConf, InspIRCd* ServerInstance)
-{
- Connections.clear();
- for (int j =0; j < ThisConf->Enumerate("database"); j++)
- {
- std::string db = ThisConf->ReadValue("database","name",j);
- std::string user = ThisConf->ReadValue("database","username",j);
- std::string pass = ThisConf->ReadValue("database","password",j);
- std::string host = ThisConf->ReadValue("database","hostname",j);
- std::string id = ThisConf->ReadValue("database","id",j);
- if ((db != "") && (host != "") && (user != "") && (id != "") && (pass != ""))
- {
- SQLConnection* ThisSQL = new SQLConnection(host,user,pass,db,id);
- Connections[id] = ThisSQL;
- }