mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-03 14:38:50 +00:00
Wrap Sync exports in CreateThread/setImmediate
This commit is contained in:
1 parent
9af6205bb7
commit
2c2f4e0661
5 files changed
+59
-39
No files matched your search
+15
-11
@@ -18,12 +18,14 @@ When selecting data it will return all matching rows and columns, otherwise it w
|
|||||||
```
|
```
|
||||||
**Sync**
|
**Sync**
|
||||||
```lua
|
```lua
|
||||||
local result = exports.oxmysql:executeSync('SELECT * FROM users WHERE identifier = ?', {playerIdentifier})
|
CreateThread(function()
|
||||||
if result then
|
local result = exports.oxmysql:executeSync('SELECT * FROM users WHERE identifier = ?', {playerIdentifier})
|
||||||
for _, v in pairs(result) do
|
if result then
|
||||||
print(v.identifier, v.firstname, v.lastname)
|
for _, v in pairs(result) do
|
||||||
|
print(v.identifier, v.firstname, v.lastname)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end)
|
||||||
```
|
```
|
||||||
=== "JavaScript"
|
=== "JavaScript"
|
||||||
**Async**
|
**Async**
|
||||||
@@ -38,10 +40,12 @@ When selecting data it will return all matching rows and columns, otherwise it w
|
|||||||
```
|
```
|
||||||
**Sync**
|
**Sync**
|
||||||
```js
|
```js
|
||||||
const result = await exports.oxmysql.executeSync('SELECT * FROM users WHERE identifier = ?', [playerIdentifier]) {
|
setImmediate(async () => {
|
||||||
if (result) {
|
const result = await exports.oxmysql.executeSync('SELECT * FROM users WHERE identifier = ?', [playerIdentifier]) {
|
||||||
result.forEach((v) => {
|
if (result) {
|
||||||
console.log(v.identifier, v.firstname, v.lastname)
|
result.forEach((v) => {
|
||||||
})
|
console.log(v.identifier, v.firstname, v.lastname)
|
||||||
}
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
```
|
```
|
||||||
+11
-7
@@ -15,10 +15,12 @@ Inserts a new entry into the database and returns the insert id for the row, if
|
|||||||
```
|
```
|
||||||
**Sync**
|
**Sync**
|
||||||
```lua
|
```lua
|
||||||
local id = exports.oxmysql:insertSync('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ', {playerIdentifier, firstName, lastName})
|
CreateThread(function()
|
||||||
if id then
|
local id = exports.oxmysql:insertSync('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ', {playerIdentifier, firstName, lastName})
|
||||||
print(id)
|
if id then
|
||||||
end
|
print(id)
|
||||||
|
end
|
||||||
|
end)
|
||||||
```
|
```
|
||||||
=== "JavaScript"
|
=== "JavaScript"
|
||||||
**Async**
|
**Async**
|
||||||
@@ -30,7 +32,9 @@ Inserts a new entry into the database and returns the insert id for the row, if
|
|||||||
```
|
```
|
||||||
**Sync**
|
**Sync**
|
||||||
```js
|
```js
|
||||||
const id = exports.oxmysql.insertSync('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ', [playerIdentifier, firstName, lastName]) {
|
setImmediate(async () => {
|
||||||
if (id)
|
const id = exports.oxmysql.insertSync('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ', [playerIdentifier, firstName, lastName]) {
|
||||||
console.log(id)
|
if (id)
|
||||||
|
console.log(id)
|
||||||
|
})
|
||||||
```
|
```
|
||||||
+11
-7
@@ -15,10 +15,12 @@ Returns the first column for a single row.
|
|||||||
```
|
```
|
||||||
**Sync**
|
**Sync**
|
||||||
```lua
|
```lua
|
||||||
local result = exports.oxmysql:scalarSync('SELECT firstname FROM users WHERE identifier = ?', {playerIdentifier})
|
CreateThread(function()
|
||||||
if result then
|
local result = exports.oxmysql:scalarSync('SELECT firstname FROM users WHERE identifier = ?', {playerIdentifier})
|
||||||
print(result.firstname)
|
if result then
|
||||||
end
|
print(result.firstname)
|
||||||
|
end
|
||||||
|
end)
|
||||||
```
|
```
|
||||||
=== "JavaScript"
|
=== "JavaScript"
|
||||||
**Async**
|
**Async**
|
||||||
@@ -30,7 +32,9 @@ Returns the first column for a single row.
|
|||||||
```
|
```
|
||||||
**Sync**
|
**Sync**
|
||||||
```js
|
```js
|
||||||
const result = await exports.oxmysql.scalarSync('SELECT firstname FROM users WHERE identifier = ?', [playerIdentifier]) {
|
setImmediate(async () => {
|
||||||
if (result)
|
const result = await exports.oxmysql.scalarSync('SELECT firstname FROM users WHERE identifier = ?', [playerIdentifier]) {
|
||||||
console.log(result.firstname)
|
if (result)
|
||||||
|
console.log(result.firstname)
|
||||||
|
})
|
||||||
```
|
```
|
||||||
+11
-7
@@ -15,10 +15,12 @@ Returns the columns for a single row.
|
|||||||
```
|
```
|
||||||
**Sync**
|
**Sync**
|
||||||
```lua
|
```lua
|
||||||
local result = exports.oxmysql:singleSync('SELECT * FROM users WHERE identifier = ?', {playerIdentifier})
|
CreateThread(function()
|
||||||
if result then
|
local result = exports.oxmysql:singleSync('SELECT * FROM users WHERE identifier = ?', {playerIdentifier})
|
||||||
print(result.identifier, result.firstname, result.lastname)
|
if result then
|
||||||
end
|
print(result.identifier, result.firstname, result.lastname)
|
||||||
|
end
|
||||||
|
end)
|
||||||
```
|
```
|
||||||
=== "JavaScript"
|
=== "JavaScript"
|
||||||
**Async**
|
**Async**
|
||||||
@@ -30,7 +32,9 @@ Returns the columns for a single row.
|
|||||||
```
|
```
|
||||||
**Sync**
|
**Sync**
|
||||||
```js
|
```js
|
||||||
const result = await exports.oxmysql.singleSync('SELECT * FROM users WHERE identifier = ?', [playerIdentifier]) {
|
setImmediate(async () => {
|
||||||
if (result)
|
const result = await exports.oxmysql.singleSync('SELECT * FROM users WHERE identifier = ?', [playerIdentifier]) {
|
||||||
console.log(result.identifier, result.firstname, result.lastname)
|
if (result)
|
||||||
|
console.log(result.identifier, result.firstname, result.lastname)
|
||||||
|
})
|
||||||
```
|
```
|
||||||
+11
-7
@@ -15,10 +15,12 @@ Updates an entry in the database and returns the number of affected rows.
|
|||||||
```
|
```
|
||||||
**Sync**
|
**Sync**
|
||||||
```lua
|
```lua
|
||||||
local id = exports.oxmysql:insertSync('UPDATE users SET firstname = ? WHERE identifier = ? ', {newName, playerIdentifier})
|
CreateThread(function()
|
||||||
if affectedRows then
|
local id = exports.oxmysql:insertSync('UPDATE users SET firstname = ? WHERE identifier = ? ', {newName, playerIdentifier})
|
||||||
print(affectedRows)
|
if affectedRows then
|
||||||
end
|
print(affectedRows)
|
||||||
|
end
|
||||||
|
end)
|
||||||
```
|
```
|
||||||
=== "JavaScript"
|
=== "JavaScript"
|
||||||
**Async**
|
**Async**
|
||||||
@@ -30,7 +32,9 @@ Updates an entry in the database and returns the number of affected rows.
|
|||||||
```
|
```
|
||||||
**Sync**
|
**Sync**
|
||||||
```js
|
```js
|
||||||
const id = exports.oxmysql.insertSync('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier]) {
|
setImmediate(async () => {
|
||||||
if (affectedRows)
|
const id = exports.oxmysql.insertSync('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier]) {
|
||||||
console.log(affectedRows)
|
if (affectedRows)
|
||||||
|
console.log(affectedRows)
|
||||||
|
})
|
||||||
```
|
```
|
||||||
Reference in new issue
Block a user