Files
overextended.github.io/pages/oxmysql/Functions/rawExecute.mdx
T
Jag 74227cc262 chore: oxmysql and ox_lib clean-up (#134)
* oxmysql and some lib interface fixes

- Various fixes throughout oxmysql
- started ox_lib audit

* chore: More clean up

- Reword some confusing descriptions
- Add some descriptions
- Type fixes
- Spelling and grammar fixes
- Swapping in `-` where `*` used to be for 
bullet point consistency

ox_lib
- Interface, ACL through GetClosestVehicle audited

* chore: Finishing up ox_lib
2023-07-03 13:13:56 +10:00

78 lines
1.8 KiB
Plaintext

---
title: rawExecute
---
import { Tab, Tabs } from 'nextra-theme-docs';
rawExecute can be used to execute frequently called queries faster and accepts multiple sets of parameters to be used with a single query.
- Date will not return the datestring commonly used in FiveM
- TINYINT 1 and BIT will not return a boolean
- You can only use ? value placeholders, ?? column placeholders and named placeholders will throw an error
Unlike [prepare](./prepare), the SELECT statement will always return an array of rows.
When using SELECT, the return value will match `query`, `single`, or `scalar` depending on the number of columns and rows selected.
## Promise
<Tabs items={['Lua', 'JS']}>
<Tab>
```lua
local response = MySQL.rawExecute.await('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ?', {
identifier
})
print(json.encode(response, { indent = true, sort_keys = true }))
```
</Tab>
<Tab>
```js
const response = await MySQL.rawExecute('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ?', [
identifier
])
console.log(JSON.stringify(response))
```
</Tab>
</Tabs>
**Aliases**
- `exports.oxmysql.rawExecute_async`
## Callback
<Tabs items={['Lua', 'JS']}>
<Tab>
```lua
MySQL.rawExecute('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ?', {
identifier
}, function(response)
print(json.encode(response, { indent = true, sort_keys = true }))
end)
```
</Tab>
<Tab>
```js
MySQL.rawExecute('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ?', [
identifier
], (response) => {
console.log(JSON.stringify(response))
})
```
</Tab>
</Tabs>
**Aliases**
- `exports.oxmysql.rawExecute`