mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-25 23:13:35 +00:00
Destroying database specifier
This commit is contained in:
parent
fd13770e87
commit
3e60b9db4a
@ -57,7 +57,7 @@ int main(int argc, char** argv) {
|
||||
Database::Connect(mysql_host, mysql_database, mysql_username, mysql_password);
|
||||
} catch (sql::SQLException& ex) {
|
||||
Game::logger->Log("AuthServer", "Got an error while connecting to the database: %s\n", ex.what());
|
||||
Database::Destroy();
|
||||
Database::Destroy("AuthServer");
|
||||
delete Game::server;
|
||||
delete Game::logger;
|
||||
return 0;
|
||||
@ -143,7 +143,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
//Delete our objects here:
|
||||
Database::Destroy();
|
||||
Database::Destroy("AuthServer");
|
||||
delete Game::server;
|
||||
delete Game::logger;
|
||||
|
||||
|
@ -61,7 +61,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
catch (sql::SQLException& ex) {
|
||||
Game::logger->Log("ChatServer", "Got an error while connecting to the database: %s\n", ex.what());
|
||||
Database::Destroy();
|
||||
Database::Destroy("ChatServer");
|
||||
delete Game::server;
|
||||
delete Game::logger;
|
||||
return 0;
|
||||
@ -150,7 +150,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
//Delete our objects here:
|
||||
Database::Destroy();
|
||||
Database::Destroy("ChatServer");
|
||||
delete Game::server;
|
||||
delete Game::logger;
|
||||
|
||||
|
@ -26,9 +26,10 @@ void Database::Connect(const string& host, const string& database, const string&
|
||||
con->setClientOption("MYSQL_OPT_RECONNECT", &myTrue);
|
||||
} //Connect
|
||||
|
||||
void Database::Destroy() {
|
||||
void Database::Destroy(std::string source) {
|
||||
if (!con) return;
|
||||
Game::logger->Log("Database", "Destroying MySQL connection!\n");
|
||||
if (source != "") Game::logger->Log("Database", "Destroying MySQL connection from %s!\n", source.c_str());
|
||||
else Game::logger->Log("Database", "Destroying MySQL connection!\n");
|
||||
con->close();
|
||||
delete con;
|
||||
} //Destroy
|
||||
|
@ -22,7 +22,7 @@ private:
|
||||
|
||||
public:
|
||||
static void Connect(const std::string& host, const std::string& database, const std::string& username, const std::string& password);
|
||||
static void Destroy();
|
||||
static void Destroy(std::string source="");
|
||||
static sql::Statement* CreateStmt();
|
||||
static sql::PreparedStatement* CreatePreppedStmt(const std::string& query);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user