fix(server/functions): return database details correctly

This commit is contained in:
Kasey FItton
2024-07-12 01:06:48 +01:00
parent 1a5d0fe1b5
commit e1aa208b61
2 changed files with 6 additions and 3 deletions
+2 -2
View File
@@ -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
+4 -1
View File
@@ -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