anope- supernets anope source code & configuration |
git clone git://git.acid.vegas/anope.git |
Log | Files | Refs | Archive | README |
utils.cpp (1652B)
1 /* 2 * 3 * (C) 2013-2022 Anope Team 4 * Contact us at team@anope.org 5 * 6 * Please read COPYING and README for further details. 7 */ 8 9 #include "irc2sql.h" 10 11 void IRC2SQL::RunQuery(const SQL::Query &q) 12 { 13 if (sql) 14 sql->Run(&sqlinterface, q); 15 } 16 17 void IRC2SQL::GetTables() 18 { 19 TableList.clear(); 20 ProcedureList.clear(); 21 EventList.clear(); 22 if (!sql) 23 return; 24 25 SQL::Result r = this->sql->RunQuery(this->sql->GetTables(prefix)); 26 for (int i = 0; i < r.Rows(); ++i) 27 { 28 const std::map<Anope::string, Anope::string> &map = r.Row(i); 29 for (std::map<Anope::string, Anope::string>::const_iterator it = map.begin(); it != map.end(); ++it) 30 TableList.push_back(it->second); 31 } 32 query = "SHOW PROCEDURE STATUS WHERE `Db` = Database();"; 33 r = this->sql->RunQuery(query); 34 for (int i = 0; i < r.Rows(); ++i) 35 { 36 ProcedureList.push_back(r.Get(i, "Name")); 37 } 38 query = "SHOW EVENTS WHERE `Db` = Database();"; 39 r = this->sql->RunQuery(query); 40 for (int i = 0; i < r.Rows(); ++i) 41 { 42 EventList.push_back(r.Get(i, "Name")); 43 } 44 } 45 46 bool IRC2SQL::HasTable(const Anope::string &table) 47 { 48 for (std::vector<Anope::string>::const_iterator it = TableList.begin(); it != TableList.end(); ++it) 49 if (*it == table) 50 return true; 51 return false; 52 } 53 54 bool IRC2SQL::HasProcedure(const Anope::string &table) 55 { 56 for (std::vector<Anope::string>::const_iterator it = ProcedureList.begin(); it != ProcedureList.end(); ++it) 57 if (*it == table) 58 return true; 59 return false; 60 } 61 62 bool IRC2SQL::HasEvent(const Anope::string &table) 63 { 64 for (std::vector<Anope::string>::const_iterator it = EventList.begin(); it != EventList.end(); ++it) 65 if (*it == table) 66 return true; 67 return false; 68 }