Stefan Pranger
3 years ago
2 changed files with 36 additions and 9 deletions
@ -0,0 +1,30 @@ |
|||||
|
#include <ctime> |
||||
|
|
||||
|
#include <db/db.h> |
||||
|
#include <db/statements/builder/SelectStatementBuilder.h> |
||||
|
|
||||
|
|
||||
|
namespace db { |
||||
|
void fetch_alarms(sql::Database *db, uint32_t interval) { |
||||
|
std::time_t now = std::time(nullptr); |
||||
|
stmt::Statement select_alarms = stmt::Statement::select().columns("dtstart, summary, description").from_table("alarms").inner_join("events", "events.rowid = alarms.eventID").where("dtstart<? AND dtstart>?").close(); |
||||
|
DEBUG << select_alarms.str(); |
||||
|
try { |
||||
|
sql::Statement query(*db, select_alarms.str()); |
||||
|
query.bind(1, now + interval); |
||||
|
query.bind(2, now); |
||||
|
DEBUG << query.getExpandedSQL(); |
||||
|
while (query.executeStep()) |
||||
|
{ |
||||
|
uint32_t dtstart = query.getColumn(0); |
||||
|
std::string summary = query.getColumn(1); |
||||
|
std::string description = query.getColumn(2); |
||||
|
DEBUG << dtstart << ", " << summary << ", " << description; |
||||
|
} |
||||
|
} |
||||
|
catch (std::exception& e) |
||||
|
{ |
||||
|
std::cout << "Exception: " << e.what() << std::endl; |
||||
|
} |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue