Huge command system overhaul
This commit is contained in:
@@ -25,23 +25,11 @@ let persistentDatabaseConnection = null;
|
||||
|
||||
function initDatabaseScript() {
|
||||
console.log("[Asshat.Database]: Initializing database script ...");
|
||||
addDatabaseCommandHandlers()
|
||||
console.log("[Asshat.Database]: Database script initialized successfully!");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function addDatabaseCommandHandlers() {
|
||||
console.log("[Asshat.Database]: Adding database command handlers ...");
|
||||
let databaseCommands = serverCommands.database;
|
||||
for(let i in databaseCommands) {
|
||||
addCommandHandler(databaseCommands[i].command, databaseCommands[i].handlerFunction);
|
||||
}
|
||||
console.log("[Asshat.Database]: Database command handlers added!");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function connectToDatabase() {
|
||||
if(persistentDatabaseConnection == null) {
|
||||
console.log("[Asshat.Database] Initializing database connection ...");
|
||||
@@ -78,6 +66,9 @@ function queryDatabase(dbConnection, queryString) {
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function escapeDatabaseString(dbConnection, unsafeString) {
|
||||
if(!dbConnection) {
|
||||
dbConnection = connectToDatabase();
|
||||
}
|
||||
return dbConnection.escapeString(unsafeString);
|
||||
}
|
||||
|
||||
@@ -106,4 +97,17 @@ function fetchQueryAssoc(dbQuery) {
|
||||
return dbQuery.fetchAssoc();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
function quickDatabaseQuery(queryString) {
|
||||
let dbConnection = connectToDatabase();
|
||||
if(dbConnection) {
|
||||
let dbQuery = queryDatabase(dbConnection, queryString);
|
||||
if(dbQuery) {
|
||||
dbQuery.free();
|
||||
}
|
||||
disconnectFromDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user