Add a Statement class to manage the sqlite3_stmt objects and avoid leaks

This commit is contained in:
louiz’
2017-06-14 00:19:15 +02:00
parent 41c23aab37
commit 9defd0ccb7
5 changed files with 61 additions and 22 deletions
+3 -3
View File
@@ -19,14 +19,14 @@ struct CountQuery: public Query
{
auto statement = this->prepare(db);
std::size_t res = 0;
if (sqlite3_step(statement) == SQLITE_ROW)
res = sqlite3_column_int64(statement, 0);
if (sqlite3_step(statement.get()) == SQLITE_ROW)
res = sqlite3_column_int64(statement.get(), 0);
else
{
log_error("Count request didn’t return a result");
return 0;
}
if (sqlite3_step(statement) != SQLITE_DONE)
if (sqlite3_step(statement.get()) != SQLITE_DONE)
log_warning("Count request returned more than one result.");
log_debug("Returning count: ", res);