mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-02 14:38:50 +00:00
improve oxmysql examples
This commit is contained in:
1 parent
9fc1d064df
commit
80cfe6b7a2
7 files changed
+99
-123
No files matched your search
@@ -5,8 +5,8 @@ Returns the number of affected rows by the query.
|
||||
|
||||
### Callback
|
||||
```lua
|
||||
-- Alias: exports.oxmysql:update
|
||||
-- Alias: MySQL.Async.execute
|
||||
-- alias: exports.oxmysql:update
|
||||
-- alias: MySQL.Async.execute
|
||||
|
||||
MySQL.update('UPDATE users SET firstname = ? WHERE identifier = ?', {newName, playerIdentifier}, function(affectedRows)
|
||||
if affectedRows then
|
||||
@@ -17,32 +17,30 @@ end)
|
||||
|
||||
### Promise
|
||||
```lua
|
||||
-- Alias: exports.oxmysql:update_async
|
||||
-- Alias: MySQL.Sync.execute
|
||||
-- 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)
|
||||
local affectedRows = MySQL.update.await('UPDATE users SET firstname = ? WHERE identifier = ?', {newName, playerIdentifier})
|
||||
if affectedRows then
|
||||
print(affectedRows)
|
||||
end
|
||||
```
|
||||
|
||||
## JavaScript
|
||||
|
||||
### Callback
|
||||
```js
|
||||
exports.oxmysql.update('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier], function(affectedRows) {
|
||||
if (affectedRows)
|
||||
exports.oxmysql.update('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier], (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)
|
||||
})
|
||||
const id = exports.oxmysql.update_async('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier])
|
||||
if (affectedRows) {
|
||||
console.log(affectedRows)
|
||||
}
|
||||
```
|
||||
Reference in new issue
Block a user