From 720669679a4f2482b78f55bbb811437ae6d9fe3f Mon Sep 17 00:00:00 2001 From: MangosArentLiterature <58055358+MangosArentLiterature@users.noreply.github.com> Date: Mon, 21 Jun 2021 22:22:02 -0500 Subject: [PATCH] Select only needed values from the DB --- core/src/db_manager.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/src/db_manager.cpp b/core/src/db_manager.cpp index 240f20c..d8e2ace 100644 --- a/core/src/db_manager.cpp +++ b/core/src/db_manager.cpp @@ -34,13 +34,13 @@ DBManager::DBManager() : QPair DBManager::isIPBanned(QString ipid) { QSqlQuery query; - query.prepare("SELECT * FROM BANS WHERE IPID = ? ORDER BY TIME DESC"); + query.prepare("SELECT TIME,REASON,DURATION FROM BANS WHERE IPID = ? ORDER BY TIME DESC"); query.addBindValue(ipid); query.exec(); if (query.first()) { - long long ban_time = query.value(4).toLongLong(); - QString reason = query.value(5).toString(); - long long duration = query.value(6).toLongLong(); + long long ban_time = query.value(0).toLongLong(); + QString reason = query.value(1).toString(); + long long duration = query.value(2).toLongLong(); if (duration == -2) return {true, reason}; long long current_time = QDateTime::currentDateTime().toSecsSinceEpoch(); @@ -54,13 +54,13 @@ QPair DBManager::isIPBanned(QString ipid) QPair DBManager::isHDIDBanned(QString hdid) { QSqlQuery query; - query.prepare("SELECT * FROM BANS WHERE HDID = ? ORDER BY TIME DESC"); + query.prepare("SELECT TIME,REASON,DURATION FROM BANS WHERE HDID = ? ORDER BY TIME DESC"); query.addBindValue(hdid); query.exec(); if (query.first()) { - long long ban_time = query.value(4).toLongLong(); - QString reason = query.value(5).toString(); - long long duration = query.value(6).toLongLong(); + long long ban_time = query.value(0).toLongLong(); + QString reason = query.value(1).toString(); + long long duration = query.value(2).toLongLong(); if (duration == -2) return {true, reason}; long long current_time = QDateTime::currentDateTime().toSecsSinceEpoch();