]> git.stg.codes - stg.git/commitdiff
Added some handy funcs to work with IBPP statements.
authorMaxim Mamontov <faust.madf@gmail.com>
Sun, 25 Jan 2015 18:21:16 +0000 (20:21 +0200)
committerMaxim Mamontov <faust.madf@gmail.com>
Sun, 25 Jan 2015 18:21:16 +0000 (20:21 +0200)
projects/stargazer/plugins/store/firebird/firebird_store.h
projects/stargazer/plugins/store/firebird/firebird_store_users.cpp

index 688f0e88651da56258aad827b29d4ff92a21c6d7..d9c6af244b30c3fbe6628282789aee5955b8d492 100644 (file)
@@ -136,4 +136,13 @@ time_t ts2time_t(const IBPP::Timestamp & ts);
 void time_t2ts(time_t t, IBPP::Timestamp * ts);
 void ym2date(int year, int month, IBPP::Date * date);
 
+template <typename T>
+inline
+T Get(IBPP::Statement st, size_t pos)
+{
+    T value;
+    st->Get(pos, value);
+    return value;
+}
+
 #endif //FIREBIRD_STORE_H
index 8c214fbf2b6ccc97ee8781b7e3065fbee1d5207c..2e92603ea3a201c5ab87c405bbc8637e40d77268 100644 (file)
@@ -127,9 +127,9 @@ return SaveStat(stat, login);
 }
 //-----------------------------------------------------------------------------
 int FIREBIRD_STORE::SaveStat(const USER_STAT & stat,
-                                 const std::string & login,
-                                 int year,
-                                 int month) const
+                             const std::string & login,
+                             int year,
+                             int month) const
 {
 IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
 IBPP::Statement st = IBPP::StatementFactory(db, tr);
@@ -147,7 +147,7 @@ try
     tr->Rollback();
     return -1;
     }
-    st->Get(1, uid);
+    int32_t uid = Get<int32_t>(st, 1);
     st->Close();
     st->Prepare("select first 1 pk_stat from tb_stats where fk_user = ? order by stats_date desc");
     st->Set(1, uid);