summaryrefslogtreecommitdiff
path: root/src/database/count_query.hpp
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-10-04 21:28:18 +0200
committerlouiz’ <louiz@louiz.org>2017-12-02 20:08:47 +0100
commit0168b96b79db2627fdba77a8712956408aa081d1 (patch)
tree5591527ed8a04be8ea04c49521d9e9c868677bd1 /src/database/count_query.hpp
parent5b27cee97272d4ae6ff30f03dc57221fa3e3183f (diff)
downloadbiboumi-0168b96b79db2627fdba77a8712956408aa081d1.tar.gz
biboumi-0168b96b79db2627fdba77a8712956408aa081d1.tar.bz2
biboumi-0168b96b79db2627fdba77a8712956408aa081d1.tar.xz
biboumi-0168b96b79db2627fdba77a8712956408aa081d1.zip
Add postgresql support
Diffstat (limited to 'src/database/count_query.hpp')
-rw-r--r--src/database/count_query.hpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/database/count_query.hpp b/src/database/count_query.hpp
index 0dde63c..b462e0f 100644
--- a/src/database/count_query.hpp
+++ b/src/database/count_query.hpp
@@ -2,6 +2,7 @@
#include <database/query.hpp>
#include <database/table.hpp>
+#include <database/statement.hpp>
#include <string>
@@ -15,20 +16,17 @@ struct CountQuery: public Query
this->body += std::move(name);
}
- int64_t execute(sqlite3* db)
+ int64_t execute(DatabaseEngine& db)
{
- auto statement = this->prepare(db);
+ auto statement = db.prepare(this->body);
int64_t res = 0;
- if (sqlite3_step(statement.get()) == SQLITE_ROW)
- res = sqlite3_column_int64(statement.get(), 0);
+ if (statement->step() != StepResult::Error)
+ res = statement->get_column_int64(0);
else
{
log_error("Count request didn’t return a result");
return 0;
}
- if (sqlite3_step(statement.get()) != SQLITE_DONE)
- log_warning("Count request returned more than one result.");
-
return res;
}
};