Files
overextended.github.io/docs/oxmysql/Usage/update.md
T
Linden 6bead3ca32 Consistent indentation and remove some files
Mixing tabs and spaces when embedding Lua can easily break MDX syntax.
2022-04-29 15:39:04 +10:00

1.1 KiB

Update

Returns the number of affected rows by the query.

Lua

Callback

-- Alias: exports.oxmysql:update
-- Alias: MySQL.Async.execute

MySQL.update('UPDATE users SET firstname = ? WHERE identifier = ?', {newName, playerIdentifier}, function(affectedRows)
    if affectedRows then
        print(affectedRows)
    end
end)

Promise

-- Alias: exports.oxmysql:update_async
-- Alias: MySQL.Sync.execute

CreateThread(function()
    local affectedRows = MySQL.update.await('UPDATE users SET firstname = ? WHERE identifier = ?', {newName, playerIdentifier})
    if affectedRows then
        print(affectedRows)
    end
end)

JavaScript

Callback

exports.oxmysql.update('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier], function(affectedRows) {
  if (affectedRows)
    console.log(affectedRows)
})

Promise

setImmediate(async () => {
  const id = exports.oxmysql.update_async('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier]) {
  if (affectedRows)
    console.log(affectedRows)
})