mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 22:21:48 +00:00
49 lines
1.1 KiB
Markdown
49 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.update
|
|
|
|
MySQL.Async.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.update
|
|
|
|
CreateThread(function()
|
|
local affectedRows = MySQL.update.await('UPDATE users SET firstname = ? WHERE identifier = ? ', {newName, playerIdentifier})
|
|
if affectedRows then
|
|
print(affectedRows)
|
|
end
|
|
end)
|
|
```
|
|
|
|
## JavaScript
|
|
|
|
### Callback
|
|
```js
|
|
exports.oxmysql.update('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier], function(affectedRows) {
|
|
if (affectedRows)
|
|
console.log(affectedRows)
|
|
})
|
|
```
|
|
|
|
### Promise
|
|
```js
|
|
setImmediate(async () => {
|
|
const id = exports.oxmysql.update_async('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier]) {
|
|
if (affectedRows)
|
|
console.log(affectedRows)
|
|
})
|
|
```
|