Files
JagandLuke 1d2c490b26 refactor: Add h1 headers to all pages missing it (#137)
* refactor: Add h1 headers to all pages missing it

* refactor: missed example h3

* change hooks example heading to bold text

---------

Co-authored-by: Luke <[email protected]>
2023-07-08 11:08:43 +02:00

80 lines
1.3 KiB
Plaintext

---
title: single
---
import { Tab, Tabs } from 'nextra-theme-docs';
# Single
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`