]> git.sesse.net Git - ccbs/blob - bigscreen/fetch_current_tournament.cpp
Lots of changes/fixes to the new translation stuff.
[ccbs] / bigscreen / fetch_current_tournament.cpp
1 #include "fetch_current_tournament.h"
2
3 FetchCurrentTournament::FetchCurrentTournament(Tournament *tourn) : tourn(tourn) {}
4 void FetchCurrentTournament::operator() (pqxx::transaction<> &t)
5 {
6         pqxx::result res( t.exec("SELECT * FROM bigscreen.active_tournament NATURAL JOIN tournaments") );
7         try {
8                 pqxx::result::tuple tournament = res.at(0);
9
10                 tourn->id = tournament["tournament"].as(tourn->id);
11                 tourn->name = tournament["tournamentname"].as(tourn->name);
12         } catch (PGSTD::out_of_range &e) {
13                 tourn->id = -1;
14                 tourn->name = "";
15         }
16 }