diff options
| author | Dark1-dev <shansarkar272@gmail.com> | 2023-03-01 21:33:55 +0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-01 21:33:55 +0600 |
| commit | 3c7253d6cdc23aac36208fa87dc6571c7cb7c5ff (patch) | |
| tree | 8b5f9425bbfc4fdd5a29155aec38893b77481359 /Database/Common/insertserver.cpp | |
| parent | de57bc38217c09a0ae4a143f631896652368ecc3 (diff) | |
| download | Masterserver-Qt5-3c7253d6cdc23aac36208fa87dc6571c7cb7c5ff.tar.gz Masterserver-Qt5-3c7253d6cdc23aac36208fa87dc6571c7cb7c5ff.zip | |
Add files via upload
Diffstat (limited to 'Database/Common/insertserver.cpp')
| -rw-r--r-- | Database/Common/insertserver.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Database/Common/insertserver.cpp b/Database/Common/insertserver.cpp new file mode 100644 index 0000000..05b2eaa --- /dev/null +++ b/Database/Common/insertserver.cpp @@ -0,0 +1,26 @@ +#include "commonactions.h" + +// insert a server into the list +bool insertServer(const QString &serverAddress, + const unsigned short &serverPort, + const QString &gamename, + const bool &directBeacon) +{ + // insert query string + QSqlQuery q; + QString insertString = "INSERT INTO serverlist (ip, queryport, gamename, f_direct) " + "VALUES (:ip, :queryport, :gamename, :directbeacon)"; + + // bind values and execute + q.prepare(insertString); + q.bindValue(":ip", serverAddress); + q.bindValue(":queryport", serverPort); + q.bindValue(":gamename", gamename); + q.bindValue(":directbeacon", ( directBeacon ? 1 : 0 ) ); // bool to int + + if ( ! q.exec() ) + return reportQuery(q); + + // was a row inserted? + return (q.numRowsAffected() > 0); +} |
