mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-02 06:28:54 +00:00
40 lines
979 B
Markdown
40 lines
979 B
Markdown
---
|
|
title: Scalar
|
|
---
|
|
Returns the first column for a single row.
|
|
|
|
!!! info "Example"
|
|
=== "Lua"
|
|
**Async**
|
|
```lua
|
|
exports.oxmysql:scalar('SELECT firstname FROM users WHERE identifier = ?', {playerIdentifier}, function(result)
|
|
if result then
|
|
print(result.firstname)
|
|
end
|
|
end)
|
|
```
|
|
**Sync**
|
|
```lua
|
|
CreateThread(function()
|
|
local result = exports.oxmysql:scalarSync('SELECT firstname FROM users WHERE identifier = ?', {playerIdentifier})
|
|
if result then
|
|
print(result.firstname)
|
|
end
|
|
end)
|
|
```
|
|
=== "JavaScript"
|
|
**Async**
|
|
```js
|
|
exports.oxmysql.scalar('SELECT firstname FROM users WHERE identifier = ?', [playerIdentifier], function(result) {
|
|
if (result)
|
|
console.log(result.firstname)
|
|
})
|
|
```
|
|
**Sync**
|
|
```js
|
|
setImmediate(async () => {
|
|
const result = await exports.oxmysql.scalarSync('SELECT firstname FROM users WHERE identifier = ?', [playerIdentifier]) {
|
|
if (result)
|
|
console.log(result.firstname)
|
|
})
|
|
``` |