Files
overextended.github.io/docs/oxmysql/Usage/insert.md
T
2022-07-07 15:02:15 +10:00

40 lines
1000 B
Markdown

# Insert
Inserts a new entry into the database and returns the insert id for the row, if valid.
## Lua
### Callback
```lua
-- alias: exports.oxmysql:insert
-- alias: MySQL.Async.insert
MySQL.insert('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?)', {playerIdentifier, firstName, lastName}, function(id)
print(id)
end)
```
### Promise
```lua
-- alias: exports.oxmysql:insert_async
-- alias: MySQL.Sync.insert
local id = MySQL.insert.await('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?)', {playerIdentifier, firstName, lastName})
print(id)
```
## JavaScript
### Callback
```js
exports.oxmysql.insert('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?)', [playerIdentifier, firstName, lastName], (id) => {
console.log(id)
})
```
### Promise
```js
const id = await exports.oxmysql.insert_async('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?)', [playerIdentifier, firstName, lastName])
console.log(id)
```