X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fsql.h;h=436cd1da8c5ed06d1340ca49fd698326879f1de0;hb=de4b1863536348520c6498e11d910acd050092a7;hp=e558d9f6bdf687d415634d9b7fc5cf0fd1adfce8;hpb=e9808ffb01876ab0ebad383de7861899a17f1a63;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/sql.h b/src/modules/sql.h index e558d9f6b..436cd1da8 100644 --- a/src/modules/sql.h +++ b/src/modules/sql.h @@ -1,16 +1,22 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2010 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2010 Daniel De Graaf * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + #ifndef INSPIRCD_SQLAPI_3 #define INSPIRCD_SQLAPI_3 @@ -127,10 +133,8 @@ class SQLQuery : public classbase { public: ModuleRef creator; - const std::string query; - SQLQuery(Module* Creator, const std::string& q) - : creator(Creator), query(q) {} + SQLQuery(Module* Creator) : creator(Creator) {} virtual ~SQLQuery() {} virtual void OnResult(SQLResult& result) = 0; @@ -148,25 +152,26 @@ class SQLProvider : public DataProvider public: SQLProvider(Module* Creator, const std::string& Name) : DataProvider(Creator, Name) {} /** Submit an asynchronous SQL request - * @param dbid The database ID to apply the request to - * @param query The query string - * @param callback The callback that the result is sent to + * @param callback The result reporting point + * @param query The hardcoded query string. If you have parameters to substitute, see below. */ - virtual void submit(SQLQuery* query) = 0; + virtual void submit(SQLQuery* callback, const std::string& query) = 0; - /** Format a parameterized query string using proper SQL escaping. - * @param q The query string, with '?' parameters - * @param p The parameters to fill in in the '?' slots + /** Submit an asynchronous SQL request + * @param callback The result reporting point + * @param format The simple parameterized query string ('?' parameters) + * @param p Parameters to fill in for the '?' entries */ - virtual std::string FormatQuery(const std::string& q, const ParamL& p) = 0; + virtual void submit(SQLQuery* callback, const std::string& format, const ParamL& p) = 0; - /** Format a parameterized query string using proper SQL escaping. - * @param q The query string, with '$foo' parameters - * @param p The map to look up parameters in + /** Submit an asynchronous SQL request. + * @param callback The result reporting point + * @param format The parameterized query string ('$name' parameters) + * @param p Parameters to fill in for the '$name' entries */ - virtual std::string FormatQuery(const std::string& q, const ParamM& p) = 0; + virtual void submit(SQLQuery* callback, const std::string& format, const ParamM& p) = 0; - /** Convenience function */ + /** Convenience function to prepare a map from a User* */ void PopulateUserInfo(User* user, ParamM& userinfo) { userinfo["nick"] = user->nick;