mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-02 14:38:50 +00:00
new docs
This commit is contained in:
1 parent
3cebaf7fa5
commit
b5eba8423f
229 files changed
+6238
-10690
No files matched your search
@@ -0,0 +1,92 @@
|
||||
---
|
||||
keywords: ['fetchAll', 'execute']
|
||||
title: Query
|
||||
---
|
||||
|
||||
import { Tab, Tabs } from 'nextra-theme-docs';
|
||||
|
||||
When selecting data, returns all matching rows and columns; otherwise, returns data like insertId, affectedRows, etc.
|
||||
|
||||
## Promise
|
||||
|
||||
<Tabs items={['Lua', 'JS']}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
local response = MySQL.query.await('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ?', {
|
||||
identifier
|
||||
})
|
||||
|
||||
if response then
|
||||
for i = 1, #response do
|
||||
local row = response[i]
|
||||
print(row.firstname, row.lastname)
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```js
|
||||
const response = await MySQL.query('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ?', [
|
||||
identifier
|
||||
])
|
||||
|
||||
if (response) {
|
||||
response.forEach((row) => {
|
||||
console.log(row.identifier, row.firstname, row.lastname)
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
**Aliases**
|
||||
|
||||
- `MySQL.Sync.fetchAll`
|
||||
- `exports.ghmattimysql.execute`
|
||||
- `exports.oxmysql.query_async`
|
||||
|
||||
## Callback
|
||||
|
||||
<Tabs items={['Lua', 'JS']}>
|
||||
<Tab>
|
||||
|
||||
```lua
|
||||
MySQL.query('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ?', {
|
||||
identifier
|
||||
}, function(response)
|
||||
if response then
|
||||
for i = 1, #response do
|
||||
local row = response[i]
|
||||
print(row.firstname, row.lastname)
|
||||
end
|
||||
end
|
||||
end)
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
||||
```js
|
||||
MySQL.query('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ?', [
|
||||
identifier
|
||||
], (response) => {
|
||||
if (response) {
|
||||
response.forEach((row) => {
|
||||
console.log(row.firstname, row.lastname)
|
||||
})
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
**Aliases**
|
||||
|
||||
- `MySQL.Async.fetchAll`
|
||||
- `exports.ghmattimysql.execute`
|
||||
- `exports.oxmysql.query`
|
||||
Reference in new issue
Block a user