mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-02 14:38:50 +00:00
update functions for 1.9.0, finally write prepare and common issues
This commit is contained in:
1 parent
c07dfc085c
commit
40dee21923
10 files changed
+227
-154
No files matched your search
+10
-10
@@ -1,39 +1,39 @@
|
||||
---
|
||||
title: Update
|
||||
title: update
|
||||
---
|
||||
Updates an entry in the database and returns the number of affected rows.
|
||||
Returns the number of affected rows when executing an UPDATE or DELETE query.
|
||||
|
||||
!!! info "Example"
|
||||
=== "Lua"
|
||||
**Async**
|
||||
**Callback**
|
||||
```lua
|
||||
exports.oxmysql:update('UPDATE users SET firstname = ? WHERE identifier = ? ', {newName, playerIdentifier}, function(affectedRows)
|
||||
MySQL.Async.update('UPDATE users SET firstname = ? WHERE identifier = ? ', {newName, playerIdentifier}, function(affectedRows)
|
||||
if affectedRows then
|
||||
print(affectedRows)
|
||||
end
|
||||
end)
|
||||
```
|
||||
**Sync**
|
||||
**Promise**
|
||||
```lua
|
||||
CreateThread(function()
|
||||
local id = exports.oxmysql:updateSync('UPDATE users SET firstname = ? WHERE identifier = ? ', {newName, playerIdentifier})
|
||||
local id = MySQL.Sync.update('UPDATE users SET firstname = ? WHERE identifier = ? ', {newName, playerIdentifier})
|
||||
if affectedRows then
|
||||
print(affectedRows)
|
||||
end
|
||||
end)
|
||||
```
|
||||
=== "JavaScript"
|
||||
**Async**
|
||||
**Callback**
|
||||
```js
|
||||
exports.oxmysql.update('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier], function(affectedRows) {
|
||||
exports.oxmysql.update_callback('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier], function(affectedRows) {
|
||||
if (affectedRows)
|
||||
console.log(affectedRows)
|
||||
})
|
||||
```
|
||||
**Sync**
|
||||
**Promise**
|
||||
```js
|
||||
setImmediate(async () => {
|
||||
const id = exports.oxmysql.updateSync('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier]) {
|
||||
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