diff --git a/server/events.lua b/server/events.lua index 34f27b9..793271e 100644 --- a/server/events.lua +++ b/server/events.lua @@ -27,8 +27,8 @@ if readyFunction ~= nil then local DatabaseInfo = QBCore.Functions.GetDatabaseInfo() if not DatabaseInfo or not DatabaseInfo.exists then return end - - local result = MySQL.query.await('SELECT * FROM information_schema.tables WHERE table_schema = "%s" AND table_name = "bans";', {DatabaseInfo.database}) + + local result = MySQL.query.await('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCEMA = ? AND TABLE_NAME = "bans";', {DatabaseInfo.database}) if result and result[1] then bansTableExists = true end diff --git a/server/functions.lua b/server/functions.lua index ec46217..c4ae93b 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -623,6 +623,8 @@ function QBCore.Functions.IsPlayerBanned(source) return false end +-- Retrieves information about the database connection. +--- @return table; A table containing the database information. function QBCore.Functions.GetDatabaseInfo() local details = { exists = false, @@ -636,6 +638,7 @@ function QBCore.Functions.GetDatabaseInfo() connectionString = connectionString:sub(9, -1) details.database = connectionString:sub(connectionString:find("/") + 1, -1):gsub("[%?]+[%w%p]*$", "") details.exists = true + return details else connectionString = { string.strsplit(";", connectionString) } @@ -644,7 +647,7 @@ function QBCore.Functions.GetDatabaseInfo() if v:match("database") then details.database = v:sub(10, #v) details.exists = true - break + return details end end end