+ ModuleSQL* Parent()
+ {
+ return (ModuleSQL*)(Module*)creator;
+ }
+
+ MySQLresult* DoBlockingQuery(const std::string& query)
+ {
+
+ /* Parse the command string and dispatch it to mysql */
+ if (CheckConnection() && !mysql_real_query(connection, query.data(), query.length()))
+ {
+ /* Successfull query */
+ MYSQL_RES* res = mysql_use_result(connection);
+ unsigned long rows = mysql_affected_rows(connection);
+ return new MySQLresult(res, rows);
+ }
+ else
+ {
+ /* XXX: See /usr/include/mysql/mysqld_error.h for a list of
+ * possible error numbers and error messages */
+ SQLerror e(SQL_QREPLY_FAIL, ConvToStr(mysql_errno(connection)) + ": " + mysql_error(connection));
+ return new MySQLresult(e);
+ }
+ }
+
+ bool CheckConnection()
+ {
+ if (!connection || mysql_ping(connection) != 0)
+ return Connect();
+ return true;
+ }
+
+ std::string GetError()
+ {
+ return mysql_error(connection);
+ }
+
+ void Close()
+ {
+ mysql_close(connection);
+ }
+
+ void submit(SQLQuery* q, const std::string& qs)
+ {
+ Parent()->Dispatcher->LockQueue();
+ Parent()->qq.push_back(QQueueItem(q, qs, this));
+ Parent()->Dispatcher->UnlockQueueWakeup();
+ }
+
+ void submit(SQLQuery* call, const std::string& q, const ParamL& p)