ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. dbPrepareString

Function

dbPrepareString

ServerDatabaseIdentical to MTA:SA

Returns the query text with values placed at ? and safely quoted. Useful when building a larger query from parts.

Syntax

string dbPrepareString(element connection, string query, mixed ...)

Arguments

connectionelement
A handle from dbConnect.
querystring
A query with ? placeholders.
...mixed
The values.

Returns

The final query text or false.

Example

local parts = {}
for _, p in ipairs(getElementsByType("player")) do
    parts[#parts + 1] = dbPrepareString(db, "(?, ?)", getPlayerSerial(p), getPlayerMoney(p))
end
if #parts > 0 then
    dbExec(db, "INSERT OR REPLACE INTO gracze (serial, kasa) VALUES " .. table.concat(parts, ","))
end