mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-28 17:01:14 +00:00
Merge pull request #1833 from seltonmt012/perf/multichar-select-index
perf(esx_multicharacter): look up characters by exact identifier instead of LIKE
This commit is contained in:
@@ -101,9 +101,17 @@ function Database:GetPlayerSlots(identifier)
|
||||
end
|
||||
|
||||
function Database:GetPlayerInfo(identifier, slots)
|
||||
local placeholders = {}
|
||||
local identifiers = {}
|
||||
|
||||
for i = 1, slots do
|
||||
placeholders[i] = "?"
|
||||
identifiers[i] = ("%s%s:%s"):format(Server.prefix, i, identifier)
|
||||
end
|
||||
|
||||
return MySQL.query.await(
|
||||
"SELECT identifier, accounts, job, job_grade, firstname, lastname, dateofbirth, sex, skin, disabled FROM users WHERE identifier LIKE ? LIMIT ?",
|
||||
{ identifier, slots })
|
||||
("SELECT identifier, accounts, job, job_grade, firstname, lastname, dateofbirth, sex, skin, disabled FROM users WHERE identifier IN (%s)"):format(table.concat(placeholders, ", ")),
|
||||
identifiers)
|
||||
end
|
||||
|
||||
function Database:SetSlots(identifier, slots)
|
||||
|
||||
@@ -14,7 +14,6 @@ function Multicharacter:SetupCharacters(source)
|
||||
ESX.Players[identifier] = source
|
||||
|
||||
local slots = Database:GetPlayerSlots(identifier)
|
||||
identifier = Server.prefix .. "%:" .. identifier
|
||||
|
||||
local rawCharacters = Database:GetPlayerInfo(identifier, slots)
|
||||
local characters
|
||||
|
||||
Reference in New Issue
Block a user