Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. bool IOBan::getData(Ban& ban) const{
  2.     Database* db = Database::getInstance();
  3.     DBQuery query;
  4.     query << "SELECT * FROM `bans` WHERE `value` = " << ban.value;
  5.     if(ban.param)
  6.         query << " AND `param` = " << ban.param;
  7.     if(ban.type != BAN_NONE)
  8.         query << " AND `type` = " << ban.type;
  9.     query << " AND `active` = 1 AND (`expires` > " << std::time(NULL) << " OR `expires` <= 0)";
  10.     DBResult* result;
  11.     if(!(result = db->storeQuery(query.str())))
  12.         return false;
  13.     ban.id = result->getDataInt("id");
  14.     ban.type = (Ban_t)result->getDataInt("type");
  15.     ban.value = result->getDataInt("value");
  16.     ban.param = result->getDataInt("param");
  17.     ban.expires = result->getDataLong("expires");
  18.     ban.added = result->getDataLong("added");
  19.     ban.adminId = result->getDataInt("admin_id");
  20.     ban.comment = result->getDataString("comment");
  21.     ban.reason = result->getDataInt("reason");
  22.     ban.action = (ViolationAction_t)result->getDataInt("action");
  23.     ban.statement = result->getDataString("statement");
  24.     result->free();
  25.     return true;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement