mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-28 17:01:16 +00:00
fix(server/functions): return database details correctly
This commit is contained in:
+2
-2
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user