Implement our own database ORM, and update the whole code to use it
Entirely replace LiteSQL fix #3271
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <database/query.hpp>
|
||||
#include <database/table.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
||||
struct CountQuery: public Query
|
||||
{
|
||||
CountQuery(std::string name):
|
||||
Query("SELECT count(*) FROM ")
|
||||
{
|
||||
this->body += std::move(name);
|
||||
}
|
||||
|
||||
std::size_t execute(sqlite3* db)
|
||||
{
|
||||
auto statement = this->prepare(db);
|
||||
std::size_t res = 0;
|
||||
if (sqlite3_step(statement) == SQLITE_ROW)
|
||||
res = sqlite3_column_int64(statement, 0);
|
||||
else
|
||||
{
|
||||
log_error("Count request didn’t return a result");
|
||||
return 0;
|
||||
}
|
||||
if (sqlite3_step(statement) != SQLITE_DONE)
|
||||
log_warning("Count request returned more than one result.");
|
||||
|
||||
log_debug("Returning count: ", res);
|
||||
return res;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user