Files
overextended.github.io/docs/oxmysql/Usage/single.md
T
Linden 3d627ba762 update oxmysql js usage
and somewhat clean up transaction docs
2022-07-12 15:21:32 +10:00

51 lines
1.0 KiB
Markdown

# Single
Returns the columns for a single row.
## Lua
### Callback
```lua
-- alias: exports.oxmysql:single
-- alias: MySQL.Async.fetchSingle
MySQL.single('SELECT * FROM users WHERE identifier = ?', {playerIdentifier}, function(row)
if row then
print(row.identifier, row.firstname, row.lastname)
end
end)
```
### Promise
```lua
-- alias: exports.oxmysql:single_async
-- alias: MySQL.Sync.fetchSingle
local row = MySQL.single.await('SELECT * FROM users WHERE identifier = ?', {playerIdentifier})
if row then
print(row.identifier, row.firstname, row.lastname)
end
```
## JavaScript
### Callback
```js
// alias: exports.oxmysql.single
MySQL.single('SELECT * FROM users WHERE identifier = ?', [playerIdentifier],(row) => {
if (row) {
console.log(row.identifier, row.firstname, row.lastname)
}
})
```
### Promise
```js
// alias: exports.oxmysql.single_async
const row = await MySQL.single('SELECT * FROM users WHERE identifier = ?', [playerIdentifier])
if (row) {
console.log(row.identifier, row.firstname, row.lastname)
}
```