mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 14:38:50 +00:00
78 lines
1.3 KiB
Plaintext
78 lines
1.3 KiB
Plaintext
---
|
|
title: Single
|
|
---
|
|
|
|
import { Tab, Tabs } from 'nextra-theme-docs';
|
|
|
|
Returns all selected columns for a single row.
|
|
|
|
## Promise
|
|
|
|
<Tabs items={['Lua', 'JS']}>
|
|
<Tab>
|
|
|
|
```lua
|
|
local row = MySQL.single.await('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ? LIMIT 1', {
|
|
identifier
|
|
})
|
|
|
|
if not row then return end
|
|
|
|
print(row.firstname, row.lastname)
|
|
```
|
|
|
|
</Tab>
|
|
<Tab>
|
|
|
|
```js
|
|
const row = await MySQL.single('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ? LIMIT 1', [
|
|
identifier
|
|
])
|
|
|
|
if (!row) return;
|
|
|
|
console.log(row.firstname, row.lastname)
|
|
```
|
|
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
**Aliases**
|
|
|
|
- `exports.oxmysql.single_async`
|
|
|
|
## Callback
|
|
|
|
<Tabs items={['Lua', 'JS']}>
|
|
<Tab>
|
|
|
|
```lua
|
|
MySQL.single('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ? LIMIT 1', {
|
|
identifier
|
|
}, function(row)
|
|
if not row then return end
|
|
|
|
print(row.firstname, row.lastname)
|
|
end)
|
|
```
|
|
|
|
</Tab>
|
|
<Tab>
|
|
|
|
```js
|
|
MySQL.single('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ? LIMIT 1', [
|
|
identifier
|
|
], (row) => {
|
|
if (!row) return;
|
|
|
|
console.log(row.firstname, row.lastname)
|
|
})
|
|
```
|
|
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
**Aliases**
|
|
|
|
- `exports.oxmysql.single`
|