diff options
author | louiz’ <louiz@louiz.org> | 2018-03-18 02:31:18 +0100 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2018-03-18 02:31:18 +0100 |
commit | 577984faf2befaa7f11a1e4a115dc8d80805fec7 (patch) | |
tree | db65417e4dc37123841309f9c9ee8d375bf9e003 /src/database/delete_query.hpp | |
parent | ad7aa5b7090f093a8a167a3fcb29c421881946f7 (diff) | |
download | biboumi-577984faf2befaa7f11a1e4a115dc8d80805fec7.tar.gz biboumi-577984faf2befaa7f11a1e4a115dc8d80805fec7.tar.bz2 biboumi-577984faf2befaa7f11a1e4a115dc8d80805fec7.tar.xz biboumi-577984faf2befaa7f11a1e4a115dc8d80805fec7.zip |
Allow the execution of multiple commands after the IRC connection
fix #3275
Diffstat (limited to 'src/database/delete_query.hpp')
-rw-r--r-- | src/database/delete_query.hpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/database/delete_query.hpp b/src/database/delete_query.hpp new file mode 100644 index 0000000..dce705b --- /dev/null +++ b/src/database/delete_query.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include <database/query.hpp> +#include <database/engine.hpp> + +class DeleteQuery: public Query +{ +public: + DeleteQuery(const std::string& name): + Query("DELETE") + { + this->body += " from " + name; + } + + DeleteQuery& where() + { + this->body += " WHERE "; + return *this; + }; + + void execute(DatabaseEngine& db) + { + auto statement = db.prepare(this->body); + if (!statement) + return; +#ifdef DEBUG_SQL_QUERIES + const auto timer = this->log_and_time(); +#endif + statement->bind(std::move(this->params)); + if (statement->step() != StepResult::Done) + log_error("Failed to execute DELETE command"); + } +}; |