#include "configreader.h"
#include "m_sqlv2.h"
+
+
class ModuleTestClient : public Module
{
private:
- Server* Srv;
+
public:
- ModuleTestClient(Server* Me)
- : Module::Module(Me), Srv(Me)
+ ModuleTestClient(InspIRCd* Me)
+ : Module::Module(Me)
{
}
virtual void OnBackgroundTimer(time_t foo)
{
- Module* target = Srv->FindFeature("SQL");
+ Module* target = ServerInstance->FindFeature("SQL");
if(target)
{
- SQLrequest foo = SQLreq(this, target, "foo", "SELECT foo, bar FROM ?", "rawr");
+ SQLrequest foo = SQLreq(this, target, "foo", "UPDATE rawr SET foo = '?' WHERE bar = 42", ConvToStr(time(NULL)));
if(foo.Send())
{
virtual char* OnRequest(Request* request)
{
- if(strcmp(SQLRESID, request->GetData()) == 0)
+ if(strcmp(SQLRESID, request->GetId()) == 0)
{
- log(DEBUG, "Got SQL result (%s)", request->GetData());
+ log(DEBUG, "Got SQL result (%s)", request->GetId());
SQLresult* res = (SQLresult*)request;
-
- log(DEBUG, "Got result with %d rows and %d columns", res->Rows(), res->Cols());
-
- for (int r = 0; r < res->Rows(); r++)
+
+ if (res->error.Id() == NO_ERROR)
{
- log(DEBUG, "Row %d:", r);
-
- for(int i = 0; i < res->Cols(); i++)
+ if(res->Cols())
{
- log(DEBUG, "\t[%s]: %s", res->ColName(i).c_str(), res->GetValue(r, i).d.c_str());
+ log(DEBUG, "Got result with %d rows and %d columns", res->Rows(), res->Cols());
+
+ for (int r = 0; r < res->Rows(); r++)
+ {
+ log(DEBUG, "Row %d:", r);
+
+ for(int i = 0; i < res->Cols(); i++)
+ {
+ log(DEBUG, "\t[%s]: %s", res->ColName(i).c_str(), res->GetValue(r, i).d.c_str());
+ }
+ }
+ }
+ else
+ {
+ log(DEBUG, "%d rows affected in query", res->Rows());
}
}
+ else
+ {
+ log(DEBUG, "SQLrequest failed: %s", res->error.Str());
+
+ }
return SQLSUCCESS;
}
- log(DEBUG, "Got unsupported API version string: %s", request->GetData());
+ log(DEBUG, "Got unsupported API version string: %s", request->GetId());
return NULL;
}
{
}
- virtual Module * CreateModule(Server* Me)
+ virtual Module * CreateModule(InspIRCd* Me)
{
return new ModuleTestClient(Me);
}