1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
18 #include "configreader.h"
21 class ModuleTestClient : public Module
27 ModuleTestClient(InspIRCd* Me)
32 void Implements(char* List)
34 List[I_OnRequest] = List[I_OnBackgroundTimer] = 1;
37 virtual Version GetVersion()
39 return Version(1, 1, 0, 0, VF_VENDOR, API_VERSION);
42 virtual void OnBackgroundTimer(time_t foo)
44 Module* target = ServerInstance->Modules->FindFeature("SQL");
48 SQLrequest foo = SQLrequest(this, target, "foo",
49 SQLquery("UPDATE rawr SET foo = '?' WHERE bar = 42") % time(NULL));
53 ServerInstance->Log(DEBUG, "Sent query, got given ID %lu", foo.id);
57 ServerInstance->Log(DEBUG, "SQLrequest failed: %s", foo.error.Str());
62 virtual char* OnRequest(Request* request)
64 if(strcmp(SQLRESID, request->GetId()) == 0)
66 ServerInstance->Log(DEBUG, "Got SQL result (%s)", request->GetId());
68 SQLresult* res = (SQLresult*)request;
70 if (res->error.Id() == NO_ERROR)
74 ServerInstance->Log(DEBUG, "Got result with %d rows and %d columns", res->Rows(), res->Cols());
76 for (int r = 0; r < res->Rows(); r++)
78 ServerInstance->Log(DEBUG, "Row %d:", r);
80 for(int i = 0; i < res->Cols(); i++)
82 ServerInstance->Log(DEBUG, "\t[%s]: %s", res->ColName(i).c_str(), res->GetValue(r, i).d.c_str());
88 ServerInstance->Log(DEBUG, "%d rows affected in query", res->Rows());
93 ServerInstance->Log(DEBUG, "SQLrequest failed: %s", res->error.Str());
100 ServerInstance->Log(DEBUG, "Got unsupported API version string: %s", request->GetId());
105 virtual ~ModuleTestClient()
110 MODULE_INIT(ModuleTestClient)