Files
overextended.github.io/docs/oxmysql/Usage/query.md
T
2023-05-31 21:23:24 +10:00

1.7 KiB

keywords, title
keywords title
fetchAll
execute
Query

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

When selecting data, returns all matching rows and columns; otherwise, returns data like insertId, affectedRows, etc.

Promise

local response = MySQL.query.await('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ?', {
    identifier
})

if response then
    for i = 1, #response do
        local row = response[i]
        print(row.firstname, row.lastname)
    end
end
const response = await MySQL.query('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ?', [
  identifier
])

if (response) {
  response.forEach((row) => {
    console.log(row.identifier, row.firstname, row.lastname)
  })
}

Aliases

  • MySQL.Sync.fetchAll
  • exports.ghmattimysql.execute
  • exports.oxmysql.query_async

Callback

MySQL.query('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ?', {
    identifier
}, function(response)
    if response then
        for i = 1, #response do
            local row = response[i]
            print(row.firstname, row.lastname)
        end
    end
end)
MySQL.query('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ?', [
  identifier
], (response) => {
  if (response) {
    response.forEach((row) => {
      console.log(row.firstname, row.lastname)
    })
  }
})

Aliases

  • MySQL.Async.fetchAll
  • exports.ghmattimysql.execute
  • exports.oxmysql.query