]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/modules/sql.h
Fix some minor oversights introduced in 859a799 and 3e557e8.
[user/henk/code/inspircd.git] / include / modules / sql.h
index 14cd60a5625012bb87c714a69d5a0c57292eef11..47da6f6bff2a3c40cad577678613ce47c8d4b9b9 100644 (file)
@@ -1,7 +1,10 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2017 Peter Powell <petpow@saberuk.com>
+ *   Copyright (C) 2015 Daniel Vassdal <shutter@canternet.org>
+ *   Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2013, 2017-2019 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2012 Robby <robby@chatbelgie.be>
  *   Copyright (C) 2010 Daniel De Graaf <danieldg@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
@@ -104,7 +107,7 @@ class SQL::Result : public classbase
        /**
         * Return the number of rows in the result.
         *
-        * Note that if you have perfomed an INSERT or UPDATE query or other
+        * Note that if you have performed an INSERT or UPDATE query or other
         * query which will not return rows, this will return the number of
         * affected rows. In this case you SHOULD NEVER access any of the result
         * set rows, as there aren't any!
@@ -122,6 +125,15 @@ class SQL::Result : public classbase
         * @param result A reference to the vector to store column names in.
         */
        virtual void GetCols(std::vector<std::string>& result) = 0;
+
+       /**
+        * Check if there's a column with the specified name in the result
+        *
+        * @param the column name
+        * @param on success, this is the column index
+        * @returns true, or false if the column is not found
+        */
+       virtual bool HasColumn(const std::string& column, size_t& index) = 0;
 };
 
 /** SQL::Error holds the error state of a request.
@@ -219,12 +231,19 @@ class SQL::Query : public classbase
  */
 class SQL::Provider : public DataProvider
 {
+ private:
+       /** The name of the database tag in the config. */
+       const std::string dbid;
+
  public:
        Provider(Module* Creator, const std::string& Name)
-               : DataProvider(Creator, Name)
+               : DataProvider(Creator, "SQL/" + Name)
        {
        }
 
+       /** Retrieves the name of the database tag in the config. */
+       const std::string& GetId() const { return dbid; }
+
        /** Submit an asynchronous SQL query.
         * @param callback The result reporting point
         * @param query The hardcoded query string. If you have parameters to substitute, see below.
@@ -251,7 +270,7 @@ inline void SQL::PopulateUserInfo(User* user, ParamMap& userinfo)
        userinfo["nick"] = user->nick;
        userinfo["host"] = user->GetRealHost();
        userinfo["ip"] = user->GetIPString();
-       userinfo["gecos"] = user->fullname;
+       userinfo["real"] = user->GetRealName();
        userinfo["ident"] = user->ident;
        userinfo["server"] = user->server->GetName();
        userinfo["uuid"] = user->uuid;