From de57bc38217c09a0ae4a143f631896652368ecc3 Mon Sep 17 00:00:00 2001 From: Dark1-dev Date: Wed, 1 Mar 2023 21:32:53 +0600 Subject: Add files via upload --- src/Database/Common/existserver.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/Database/Common/existserver.cpp (limited to 'src/Database/Common/existserver.cpp') diff --git a/src/Database/Common/existserver.cpp b/src/Database/Common/existserver.cpp new file mode 100644 index 0000000..9609948 --- /dev/null +++ b/src/Database/Common/existserver.cpp @@ -0,0 +1,21 @@ +#include "commonactions.h" + +bool existServer(const QString &serverAddress, + const unsigned short &serverPort) +{ + // find existing entry + QSqlQuery q; + QString selectString = "SELECT id FROM serverlist " + "WHERE ip = :ip AND queryport = :queryport "; + + // bind values and execute + q.prepare(selectString); + q.bindValue(":ip", serverAddress); + q.bindValue(":queryport", serverPort); + + if ( ! q.exec() ) + return reportQuery(q); + + // was a row/server found? + return q.next(); +} -- cgit v1.2.3