diff options
author | louiz’ <louiz@louiz.org> | 2018-09-03 22:26:57 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2018-09-03 22:26:57 +0200 |
commit | 193302b0de20df6adc090eaeaa84cfd286be724a (patch) | |
tree | b9e0e0f75b5cd74911a42a7fcd0f1477971391ff /src/database/delete_query.hpp | |
parent | 56651cb5c29cc50ddf3c62c37167fa0b9389bfde (diff) | |
parent | 28acbed948e1c281f9de6132164e42d0ed20c32f (diff) | |
download | biboumi-193302b0de20df6adc090eaeaa84cfd286be724a.tar.gz biboumi-193302b0de20df6adc090eaeaa84cfd286be724a.tar.bz2 biboumi-193302b0de20df6adc090eaeaa84cfd286be724a.tar.xz biboumi-193302b0de20df6adc090eaeaa84cfd286be724a.zip |
Merge branch 'master' into debian
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"); + } +}; |