DbExec

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search

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.