1
0
mirror of https://github.com/anope/anope.git synced 2026-07-09 17:43:12 +02:00

Modified the SQL API to allow unescaped parameters (useful for passing row names and NULL values)

This commit is contained in:
DukePyrolator
2012-04-08 12:30:48 +02:00
parent 9d249ef96f
commit 9e1fda2a44
2 changed files with 13 additions and 5 deletions
+11 -3
View File
@@ -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) { }
}