From 972edd0ff3b6750d270b79407cc8407c413d2082 Mon Sep 17 00:00:00 2001 From: danieldg Date: Wed, 2 Sep 2009 00:50:58 +0000 Subject: Add initial query support to m_mysql [patch by Athenon] git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11642 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/extra/m_mysql.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/modules') diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 06c2a13b6..cff09d9b4 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -305,6 +305,7 @@ class SQLConnection : public classbase std::map thisrow; bool Enabled; ModuleSQL* Parent; + std::string initquery; public: @@ -336,6 +337,9 @@ class SQLConnection : public classbase if (!CheckConnection()) return; + if( !initquery.empty() ) + mysql_query(connection,initquery.c_str()); + /* Parse the command string and dispatch it to mysql */ SQLrequest& req = queue.front(); @@ -507,6 +511,11 @@ class SQLConnection : public classbase return host.host; } + void setInitialQuery(std::string init) + { + initquery = init; + } + void SetEnable(bool Enable) { Enabled = Enable; @@ -617,6 +626,7 @@ void LoadDatabases(ConfigReader* conf, InspIRCd* ServerInstance, ModuleSQL* Pare host.user = conf->ReadValue("database", "username", j); host.pass = conf->ReadValue("database", "password", j); host.ssl = conf->ReadFlag("database", "ssl", j); + std::string initquery = conf->ReadValue("database", "initialquery", j); if (HasHost(host)) continue; @@ -625,6 +635,8 @@ void LoadDatabases(ConfigReader* conf, InspIRCd* ServerInstance, ModuleSQL* Pare { SQLConnection* ThisSQL = new SQLConnection(host, Parent); Connections[host.id] = ThisSQL; + + ThisSQL->setInitialQuery(initquery); } } ConnectDatabases(ServerInstance, Parent); -- cgit v1.2.3