X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fextra%2Fm_mysql.cpp;h=0a7d4d993ce6d78a4e5c91d7d86e15fa004bac4d;hb=780dda83ba3857bc3c330d4b5d38bb251a9d879b;hp=a16a293d75da88d9e3a357b71ddc58a9c4ceb5cd;hpb=b6f57c0f06f4905b04de6ec2069522d2263626c4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index a16a293d7..0a7d4d993 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -145,7 +145,7 @@ class MySQLresult : public SQL::Result std::vector colnames; std::vector fieldlists; - MySQLresult(MYSQL_RES* res, int affected_rows) : err(SQL::NO_ERROR), currentrow(0), rows(0) + MySQLresult(MYSQL_RES* res, int affected_rows) : err(SQL::SUCCESS), currentrow(0), rows(0) { if (affected_rows >= 1) { @@ -203,6 +203,19 @@ class MySQLresult : public SQL::Result result.assign(colnames.begin(), colnames.end()); } + bool HasColumn(const std::string& column, size_t& index) + { + for (size_t i = 0; i < colnames.size(); ++i) + { + if (colnames[i] == column) + { + index = i; + return true; + } + } + return false; + } + SQL::Field GetValue(int row, int column) { if ((row >= 0) && (row < rows) && (column >= 0) && (column < (int)fieldlists[row].size())) @@ -259,7 +272,7 @@ class SQLConnection : public SQL::Provider std::string user = config->getString("user"); std::string pass = config->getString("pass"); std::string dbname = config->getString("name"); - int port = config->getInt("port"); + unsigned int port = config->getUInt("port", 3306); bool rv = mysql_real_connect(connection, host.c_str(), user.c_str(), pass.c_str(), dbname.c_str(), port, NULL, 0); if (!rv) return rv; @@ -541,7 +554,7 @@ void DispatcherThread::OnNotify() for(ResultQueue::iterator i = Parent->rq.begin(); i != Parent->rq.end(); i++) { MySQLresult* res = i->r; - if (res->err.code == SQL::NO_ERROR) + if (res->err.code == SQL::SUCCESS) i->q->OnResult(*res); else i->q->OnError(res->err);