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

Function

dbExecAwait

ServerDatabaseTrilogy Hub only

Runs a write query and waits for the database to confirm it. Inside an async task the server keeps running in the meantime. Returns the number of affected rows and the id of the new row.

Syntax

bool, int, int dbExecAwait(element connection, string query [, mixed ...])

Arguments

connectionelement
A connection from dbConnect.
querystring
An SQL query with ? placeholders.
...mixed, optional
Values for the ? placeholders.

Returns

true, affected rows, insertId; false and an error message if the write failed.

Example

async(function()
    local ok, rows, id = dbExecAwait(db, "INSERT INTO cars (owner, model) VALUES (?, ?)", "Jan", 411)
    if ok then print("nowe auto nr " .. id) else print("błąd: " .. tostring(rows)) end
end)

See also