Files
overextended.github.io/docs/oxmysql/Usage/scalar.md
T
Maciej Ratyński 8ca3c1bdfc Update for docs (#116)
* Update for docs

* More changes and fix
2023-04-21 00:07:57 +10:00

990 B

Scalar

Returns the first column for a single row.

Lua

Callback

-- alias: exports.oxmysql:scalar
-- alias: MySQL.Async.fetchScalar
-- alias: exports.ghmattimysql:scalar

MySQL.scalar('SELECT firstname FROM users WHERE identifier = ?', {playerIdentifier}, function(firstname)
    print(firstname)
end)

Promise

-- alias: exports.oxmysql:scalar_async
-- alias: MySQL.Sync.fetchScalar
-- alias: exports.ghmattimysql:scalarSync

local firstname = MySQL.scalar.await('SELECT firstname FROM users WHERE identifier = ?', {playerIdentifier})
print(firstname)

JavaScript

Callback

// alias: exports.oxmysql.scalar

MySQL.scalar('SELECT firstname FROM users WHERE identifier = ?', [playerIdentifier], (firstname) => {
  console.log(firstname)
})

Promise

// alias: exports.oxmysql.scalar_async

const firstname = await MySQL.scalar('SELECT firstname FROM users WHERE identifier = ?', [playerIdentifier])
console.log(firstname)