DbExec: Difference between revisions
Jump to navigation
Jump to search
Automatyczna aktualizacja dokumentacji funkcji |
Complete Lua function catalog |
||
| Line 40: | Line 40: | ||
* Use placeholders instead of concatenating untrusted values into SQL. | * Use placeholders instead of concatenating untrusted values into SQL. | ||
[[Category:Lua Functions]] | |||
[[Category:Server Functions]] | [[Category:Server Functions]] | ||
[[Category:Database Functions]] | [[Category:Database Functions]] | ||
Latest revision as of 09:52, 15 August 2026
dbExec
Executes a prepared SQL statement when no row result is required.
Syntax
bool dbExec(DatabaseConnection connection, string statement, ...)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
connection |
DatabaseConnection |
yes | The connection used to execute the statement. |
statement |
string |
yes | SQL containing ? value placeholders.
|
... |
nil/bool/number/string |
no | Values bound to the placeholders. |
Returns
Returns true when the statement is queued successfully; otherwise returns false.
Examples
Update a player's level safely:
local ok = dbExec(db,
"UPDATE players SET level = ? WHERE id = ?",
newLevel,
playerId
)
if not ok then
outputDebugString("Could not queue level update", 1)
end
Notes
- Available only in server-side resource scripts.
- Use placeholders instead of concatenating untrusted values into SQL.