mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-04 14:38:48 +00:00
finish moving ox_mysql docs
This commit is contained in:
1 parent
7f636ad7e7
commit
b912eec843
6 files changed
+24
-20
No files matched your search
@@ -3,7 +3,7 @@ title: insert
|
||||
---
|
||||
Inserts a new entry into the database and returns the insert id for the row, if valid.
|
||||
|
||||
:::tip Example
|
||||
:::info Example
|
||||
Lua
|
||||
|
||||
**Callback**
|
||||
@@ -23,11 +23,11 @@ local id = MySQL.insert.await('INSERT INTO users (identifier, firstname, lastnam
|
||||
print(id)
|
||||
end)
|
||||
```
|
||||
=== JavaScript"
|
||||
JavaScript
|
||||
|
||||
**Callback**
|
||||
```js
|
||||
exports.oxmysql.insert('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ', [playerIdentifier,
|
||||
firstName, lastName], function(id) {
|
||||
exports.oxmysql.insert('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ', [playerIdentifier, firstName, lastName], function(id) {
|
||||
console.log(id)
|
||||
})
|
||||
```
|
||||
|
||||
@@ -10,8 +10,8 @@ Prepare can be used to execute frequently called queries faster and accepts mult
|
||||
|
||||
When using SELECT, the return value will match `fetchAll, fetchSingle, or fetchScalar` depending on the number of columns and rows selected.
|
||||
|
||||
!!! info "Example"
|
||||
=== "Lua"
|
||||
:::info Example
|
||||
Lua
|
||||
|
||||
**Callback**
|
||||
```lua
|
||||
@@ -31,7 +31,6 @@ When using SELECT, the return value will match `fetchAll, fetchSingle, or fetchS
|
||||
-- Alias: exports.oxmysql:prepare_async
|
||||
-- Alias: MySQL.Sync.prepare
|
||||
|
||||
|
||||
CreateThread(function()
|
||||
local result = MySQL.prepare.await('SELECT * FROM users WHERE identifier = ?', {playerIdentifier})
|
||||
if result then
|
||||
@@ -42,7 +41,7 @@ When using SELECT, the return value will match `fetchAll, fetchSingle, or fetchS
|
||||
end)
|
||||
```
|
||||
|
||||
=== "JavaScript"
|
||||
JavaScript
|
||||
|
||||
**Callback**
|
||||
```js
|
||||
@@ -65,6 +64,7 @@ When using SELECT, the return value will match `fetchAll, fetchSingle, or fetchS
|
||||
}
|
||||
})()
|
||||
```
|
||||
:::
|
||||
|
||||
As mentioned above, you can utilise an array of parameters for a transaction-like query without the rollback; reducing the number of exports being performed reduces strain on the server. Included below is some examples of using prepare in ESX Legacy.
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ title: query
|
||||
Generic function that can be utilised for any query.
|
||||
When selecting data it will return all matching rows and columns, otherwise it will return field data such as insertid, affectedRows, etc.
|
||||
|
||||
!!! info "Example"
|
||||
=== "Lua"
|
||||
:::info Example
|
||||
Lua
|
||||
|
||||
**Callback**
|
||||
```lua
|
||||
@@ -35,7 +35,7 @@ When selecting data it will return all matching rows and columns, otherwise it w
|
||||
end)
|
||||
```
|
||||
|
||||
=== "JavaScript"
|
||||
JavaScript
|
||||
|
||||
**Callback**
|
||||
```js
|
||||
@@ -58,3 +58,4 @@ When selecting data it will return all matching rows and columns, otherwise it w
|
||||
}
|
||||
})()
|
||||
```
|
||||
:::
|
||||
@@ -3,8 +3,8 @@ title: scalar
|
||||
---
|
||||
Returns the first column for a single row.
|
||||
|
||||
!!! info "Example"
|
||||
=== "Lua"
|
||||
:::info Example
|
||||
Lua
|
||||
|
||||
**Callback**
|
||||
```lua
|
||||
@@ -26,7 +26,7 @@ Returns the first column for a single row.
|
||||
end)
|
||||
```
|
||||
|
||||
=== "JavaScript"
|
||||
JavaScript
|
||||
|
||||
**Callback**
|
||||
```js
|
||||
@@ -41,3 +41,4 @@ Returns the first column for a single row.
|
||||
console.log(firstname)
|
||||
})()
|
||||
```
|
||||
:::
|
||||
@@ -3,8 +3,8 @@ title: single
|
||||
---
|
||||
Returns the columns for a single row.
|
||||
|
||||
!!! info "Example"
|
||||
=== "Lua"
|
||||
:::info Example
|
||||
Lua
|
||||
|
||||
**Callback**
|
||||
```lua
|
||||
@@ -30,7 +30,7 @@ Returns the columns for a single row.
|
||||
end)
|
||||
```
|
||||
|
||||
=== "JavaScript"
|
||||
JavaScript
|
||||
|
||||
**Callback**
|
||||
```js
|
||||
@@ -47,3 +47,4 @@ Returns the columns for a single row.
|
||||
console.log(result.identifier, result.firstname, result.lastname)
|
||||
})
|
||||
```
|
||||
:::
|
||||
@@ -3,8 +3,8 @@ title: update
|
||||
---
|
||||
Returns the number of affected rows by the query.
|
||||
|
||||
!!! info "Example"
|
||||
=== "Lua"
|
||||
:::info Example
|
||||
Lua
|
||||
|
||||
**Callback**
|
||||
```lua
|
||||
@@ -30,7 +30,7 @@ Returns the number of affected rows by the query.
|
||||
end)
|
||||
```
|
||||
|
||||
=== "JavaScript"
|
||||
JavaScript
|
||||
|
||||
**Callback**
|
||||
```js
|
||||
@@ -47,3 +47,4 @@ Returns the number of affected rows by the query.
|
||||
console.log(affectedRows)
|
||||
})
|
||||
```
|
||||
:::
|
||||
Reference in new issue
Block a user