Rename directory and fix JS Sync examples

This commit is contained in:
Linden committed 2021-10-25 07:55:07 +11:00
1 parent 2b40fafa7f
commit 9af6205bb7
8 files changed
+3 -3

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
---
title: Execute
---
Generic function that can be utilised for any query, synonymous with fetch.
When selecting data it will return all matching rows and columns, otherwise it will return field data such as insertid, affectedRows, etc.
!!! info "Example"
=== "Lua"
**Async**
```lua
exports.oxmysql:execute('SELECT * FROM users WHERE identifier = ?', {playerIdentifier}, function(result)
if result then
for _, v in pairs(result) do
print(v.identifier, v.firstname, v.lastname)
end
end
end)
```
**Sync**
```lua
local result = exports.oxmysql:executeSync('SELECT * FROM users WHERE identifier = ?', {playerIdentifier})
if result then
for _, v in pairs(result) do
print(v.identifier, v.firstname, v.lastname)
end
end
```
=== "JavaScript"
**Async**
```js
exports.oxmysql.execute('SELECT * FROM users WHERE identifier = ?', [playerIdentifier], function(result) {
if (result) {
result.forEach((v) => {
console.log(v.identifier, v.firstname, v.lastname)
})
}
})
```
**Sync**
```js
const result = await exports.oxmysql.executeSync('SELECT * FROM users WHERE identifier = ?', [playerIdentifier]) {
if (result) {
result.forEach((v) => {
console.log(v.identifier, v.firstname, v.lastname)
})
}
```