Files
overextended.github.io/pages/oxmysql/Functions/insert.mdx
T
JagandLuke 1d2c490b26 refactor: Add h1 headers to all pages missing it (#137)
* refactor: Add h1 headers to all pages missing it

* refactor: missed example h3

* change hooks example heading to bold text

---------

Co-authored-by: Luke <[email protected]>
2023-07-08 11:08:43 +02:00

76 lines
1.3 KiB
Plaintext

---
title: insert
---
import { Tab, Tabs } from 'nextra-theme-docs';
# Insert
Inserts a new entry into the database and returns the insert id for the row, if valid.
## Promise
<Tabs items={['Lua', 'JS']}>
<Tab>
```lua
local id = MySQL.insert.await('INSERT INTO `users` (identifier, firstname, lastname) VALUES (?, ?, ?)', {
identifier, firstName, lastName
})
print(id)
```
</Tab>
<Tab>
```js
const id = await MySQL.insert('INSERT INTO `users` (identifier, firstname, lastname) VALUES (?, ?, ?)', [
identifier, firstName, lastName
])
console.log(id)
```
</Tab>
</Tabs>
**Aliases**
- `MySQL.Sync.insert`
- `exports.ghmattimysql.executeSync`
- `exports.oxmysql.insert_async`
## Callback
<Tabs items={['Lua', 'JS']}>
<Tab>
```lua
MySQL.insert('INSERT INTO `users` (identifier, firstname, lastname) VALUES (?, ?, ?)', {
identifier, firstName, lastName
}, function(id)
print(id)
end)
```
</Tab>
<Tab>
```js
MySQL.insert('INSERT INTO `users` (identifier, firstname, lastname) VALUES (?, ?, ?)', [
identifier, firstName, lastName
], (id) => {
console.log(id)
})
```
</Tab>
</Tabs>
**Aliases**
- `MySQL.Async.insert`
- `exports.ghmattimysql.execute`
- `exports.oxmysql.insert`