dbPrepareString
Server
Fills an SQL's placeholders with escaped values, without running it.
string|false dbPrepareString(element connection, string sql, any ...)
Parameters
| Name | Type | Description |
|---|---|---|
| connection | element | A connection from dbConnect. |
| sql | string | The SQL statement, with ? and ?? as placeholders. |
| ... | any | The placeholders' values: strings, numbers, booleans or nil. |
Returns
The ready SQL, or false if the number of values does not match the placeholders.
Placeholders
?takes the next value, escaped:nilbecomesNULL, booleans become1or0and strings are quoted.??takes a string as an escaped table or column identifier.- The number of values must match the number of placeholders.
Example
local where = dbPrepareString(db, "WHERE ?? = ?", "account", accountId)
dbExec(db, "DELETE FROM players " .. where)