Files
overextended.github.io/docs/oxmysql/Usage/update.md
T
Maciej Ratyński 8ca3c1bdfc Update for docs (#116)
* Update for docs

* More changes and fix
2023-04-21 00:07:57 +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
-- alias: exports.ghmattimysql: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
-- alias: exports.ghmattimysql:executeSync

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

JavaScript

Callback

// alias: exports.oxmysql.update

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

Promise

// alias: exports.oxmysql.update_async

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