mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 22:21:48 +00:00
56 lines
1.1 KiB
Markdown
56 lines
1.1 KiB
Markdown
# Update
|
|
|
|
Returns the number of affected rows by the query.
|
|
|
|
## Lua
|
|
|
|
### Callback
|
|
|
|
```lua
|
|
-- 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
|
|
|
|
```lua
|
|
-- alias: exports.oxmysql:update_async
|
|
-- alias: MySQL.Sync.execute
|
|
|
|
local affectedRows = MySQL.update.await('UPDATE users SET firstname = ? WHERE identifier = ?', {newName, playerIdentifier})
|
|
if affectedRows then
|
|
print(affectedRows)
|
|
end
|
|
```
|
|
|
|
## JavaScript
|
|
|
|
### Callback
|
|
|
|
```js
|
|
// alias: exports.oxmysql.update
|
|
|
|
MySQL.update('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier], (affectedRows) => {
|
|
if (affectedRows) {
|
|
console.log(affectedRows)
|
|
}
|
|
})
|
|
```
|
|
|
|
### Promise
|
|
|
|
```js
|
|
// alias: exports.oxmysql.update_async
|
|
|
|
const id = MySQL.update('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier])
|
|
if (affectedRows) {
|
|
console.log(affectedRows)
|
|
}
|
|
```
|