1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 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)
30 Implementation eventlist[] = { I_OnRequest, I_OnBackgroundTimer };
31 ServerInstance->Modules->Attach(eventlist, this, 2);
35 virtual Version GetVersion()
37 return Version(1, 2, 0, 0, VF_VENDOR, API_VERSION);
40 virtual void OnBackgroundTimer(time_t)
42 Module* target = ServerInstance->Modules->FindFeature("SQL");
46 SQLrequest foo = SQLrequest(this, target, "foo",
47 SQLquery("UPDATE rawr SET foo = '?' WHERE bar = 42") % time(NULL));
51 ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Sent query, got given ID %lu", foo.id);
55 ServerInstance->Logs->Log("m_testclient.so", DEBUG, "SQLrequest failed: %s", foo.error.Str());
60 virtual const char* OnRequest(Request* request)
62 if(strcmp(SQLRESID, request->GetId()) == 0)
64 ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Got SQL result (%s)", request->GetId());
66 SQLresult* res = (SQLresult*)request;
68 if (res->error.Id() == NO_ERROR)
72 ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Got result with %d rows and %d columns", res->Rows(), res->Cols());
74 for (int r = 0; r < res->Rows(); r++)
76 ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Row %d:", r);
78 for(int i = 0; i < res->Cols(); i++)
80 ServerInstance->Logs->Log("m_testclient.so", DEBUG, "\t[%s]: %s", res->ColName(i).c_str(), res->GetValue(r, i).d.c_str());
86 ServerInstance->Logs->Log("m_testclient.so", DEBUG, "%d rows affected in query", res->Rows());
91 ServerInstance->Logs->Log("m_testclient.so", DEBUG, "SQLrequest failed: %s", res->error.Str());
98 ServerInstance->Logs->Log("m_testclient.so", DEBUG, "Got unsupported API version string: %s", request->GetId());
103 virtual ~ModuleTestClient()
108 MODULE_INIT(ModuleTestClient)