Use new query assoc stuff

This commit is contained in:
Vortrex
2022-12-11 02:02:55 -06:00
parent 4cf72b610e
commit 8350edac74

View File

@@ -314,18 +314,14 @@ function loadGlobalConfig() {
// =========================================================================== // ===========================================================================
function loadServerConfigFromGameAndPort(gameId, port) { async function loadServerConfigFromGameAndPort(gameId, port) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if (dbConnection) { if (dbConnection) {
let dbQueryString = `SELECT * FROM svr_main WHERE svr_game = ${gameId} AND svr_port = ${port} LIMIT 1;`; let dbQueryString = `SELECT * FROM svr_main WHERE svr_game = ${gameId} AND svr_port = ${port} LIMIT 1;`;
let dbQuery = queryDatabase(dbConnection, dbQueryString); let dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
if (dbQuery) { if (dbAssoc.length > 0) {
if (dbQuery.numRows > 0) { let tempServerConfigData = new ServerConfigData(dbAssoc[0]);
let dbAssoc = fetchQueryAssoc(dbQuery); return tempServerConfigData;
let tempServerConfigData = new ServerConfigData(dbAssoc);
freeDatabaseQuery(dbQuery);
return tempServerConfigData;
}
} }
disconnectFromDatabase(dbConnection); disconnectFromDatabase(dbConnection);
} }
@@ -334,18 +330,15 @@ function loadServerConfigFromGameAndPort(gameId, port) {
// =========================================================================== // ===========================================================================
function loadServerConfigFromGame(gameId) { async function loadServerConfigFromGame(gameId) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if (dbConnection) { if (dbConnection) {
let dbQueryString = `SELECT * FROM svr_main WHERE svr_game = ${gameId} LIMIT 1;`; let dbQueryString = `SELECT * FROM svr_main WHERE svr_game = ${gameId} LIMIT 1;`;
let dbQuery = queryDatabase(dbConnection, dbQueryString); let dbAssocArray = await fetchQueryAssoc(dbConnection, dbQueryString);
if (dbQuery) { logToConsole(LOG_DEBUG | LOG_WARN, `${dbAssocArray[0]}`);
if (dbQuery.numRows > 0) { if (dbAssocArray.length > 0) {
let dbAssoc = fetchQueryAssoc(dbQuery); let tempServerConfigData = new ServerConfigData(dbAssocArray[0]);
let tempServerConfigData = new ServerConfigData(dbAssoc); return tempServerConfigData;
freeDatabaseQuery(dbQuery);
return tempServerConfigData;
}
} }
disconnectFromDatabase(dbConnection); disconnectFromDatabase(dbConnection);
} }
@@ -354,21 +347,17 @@ function loadServerConfigFromGame(gameId) {
// =========================================================================== // ===========================================================================
function loadServerConfigFromId(tempServerId) { async function loadServerConfigFromId(tempServerId) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if (dbConnection) { if (dbConnection) {
let dbQueryString = `SELECT * FROM svr_main WHERE svr_id = ${tempServerId} LIMIT 1;`; let dbQueryString = `SELECT * FROM svr_main WHERE svr_id = ${tempServerId} LIMIT 1;`;
let dbQuery = queryDatabase(dbConnection, dbQueryString); let dbAssoc = await fetchQueryAssoc(dbConnection, dbQueryString);
if (dbQuery) { if (dbAssoc.length > 0) {
if (dbQuery.numRows > 0) { let tempServerConfigData = new ServerConfigData(dbAssoc[0]);
let dbAssoc = fetchQueryAssoc(dbQuery); return tempServerConfigData;
let tempServerConfigData = new ServerConfigData(dbAssoc);
freeDatabaseQuery(dbQuery);
return tempServerConfigData;
}
} }
disconnectFromDatabase(dbConnection);
} }
disconnectFromDatabase(dbConnection);
return false; return false;
} }