]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/sql.h
Merge pull request #92 from Robby-/insp20-headers
[user/henk/code/inspircd.git] / src / modules / sql.h
index e558d9f6bdf687d415634d9b7fc5cf0fd1adfce8..436cd1da8c5ed06d1340ca49fd698326879f1de0 100644 (file)
@@ -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 <danieldg@inspircd.org>
  *
- * 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 <http://www.gnu.org/licenses/>.
  */
 
+
 #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;