Allow the execution of multiple commands after the IRC connection

fix #3275
This commit is contained in:
louiz’
2018-03-18 02:31:18 +01:00
parent ad7aa5b709
commit 577984faf2
10 changed files with 159 additions and 20 deletions
+33
View File
@@ -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");
}
};