summaryrefslogtreecommitdiff
path: root/modules/extra/sql.h
diff options
context:
space:
mode:
authorDukePyrolator <DukePyrolator@anope.org>2012-04-08 12:30:48 +0200
committerDukePyrolator <DukePyrolator@anope.org>2012-04-08 12:30:48 +0200
commit9e1fda2a44dee120e26acc6e51fbe779eea97712 (patch)
treeba47ff0354fe3b4302dffc4c7108e5bf26d3048c /modules/extra/sql.h
parent9d249ef96f7fa1e6460abb9263417652d7e49c3b (diff)
Modified the SQL API to allow unescaped parameters (useful for passing row names and NULL values)
Diffstat (limited to 'modules/extra/sql.h')
-rw-r--r--modules/extra/sql.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/modules/extra/sql.h b/modules/extra/sql.h
index 0b27fe744..b23466dee 100644
--- a/modules/extra/sql.h
+++ b/modules/extra/sql.h
@@ -11,10 +11,17 @@ class SQLException : public ModuleException
/** A SQL query
*/
+
+struct QueryData
+{
+ Anope::string data;
+ bool escape;
+};
+
struct SQLQuery
{
Anope::string query;
- std::map<Anope::string, Anope::string> parameters;
+ std::map<Anope::string, QueryData> parameters;
SQLQuery() { }
SQLQuery(const Anope::string &q) : query(q) { }
@@ -36,12 +43,13 @@ struct SQLQuery
return !(*this == other);
}
- template<typename T> void setValue(const Anope::string &key, const T& value)
+ template<typename T> void setValue(const Anope::string &key, const T& value, bool escape = true)
{
try
{
Anope::string string_value = stringify(value);
- this->parameters[key] = string_value;
+ this->parameters[key].data = string_value;
+ this->parameters[key].escape = escape;
}
catch (const ConvertException &ex) { }
}