Files
overextended.github.io/docs/oxmysql/Usage/single.md
T
Linden 6bead3ca32 Consistent indentation and remove some files
Mixing tabs and spaces when embedding Lua can easily break MDX syntax.
2022-04-29 15:39:04 +10:00

1.1 KiB

Single

Returns the columns for a single row.

Lua

Callback

-- Alias: exports.oxmysql:single
-- Alias: MySQL.Async.fetchSingle

MySQL.single('SELECT * FROM users WHERE identifier = ?', {playerIdentifier}, function(result)
    if result then
        print(result.identifier, result.firstname, result.lastname)
    end
end)

Promise

-- Alias: exports.oxmysql:single_async
-- Alias: MySQL.Sync.fetchSingle

CreateThread(function()
    local result = MySQL.single.await('SELECT * FROM users WHERE identifier = ?', {playerIdentifier})
    if result then
        print(result.identifier, result.firstname, result.lastname)
    end
end)

JavaScript

Callback

exports.oxmysql.single('SELECT * FROM users WHERE identifier = ?', [playerIdentifier], function(result) {
  if (result)
    console.log(result.identifier, result.firstname, result.lastname)
})

Promise

setImmediate(async () => {
  const result = await exports.oxmysql.single_async('SELECT * FROM users WHERE identifier = ?', [playerIdentifier]) {
  if (result)
    console.log(result.identifier, result.firstname, result.lastname)
})