finish moving ox_mysql docs

This commit is contained in:
N-fire committed 2022-03-02 13:40:28 +01:00
1 parent 7f636ad7e7
commit b912eec843
6 files changed
+24 -20

No files matched your search

+4 -4
View File
@@ -3,7 +3,7 @@ title: insert
--- ---
Inserts a new entry into the database and returns the insert id for the row, if valid. Inserts a new entry into the database and returns the insert id for the row, if valid.
:::tip Example :::info Example
Lua Lua
**Callback** **Callback**
@@ -23,11 +23,11 @@ local id = MySQL.insert.await('INSERT INTO users (identifier, firstname, lastnam
print(id) print(id)
end) end)
``` ```
=== JavaScript" JavaScript
**Callback** **Callback**
```js ```js
exports.oxmysql.insert('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ', [playerIdentifier, exports.oxmysql.insert('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ', [playerIdentifier, firstName, lastName], function(id) {
firstName, lastName], function(id) {
console.log(id) console.log(id)
}) })
``` ```
+4 -4
View File
@@ -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. When using SELECT, the return value will match `fetchAll, fetchSingle, or fetchScalar` depending on the number of columns and rows selected.
!!! info "Example" :::info Example
=== "Lua" Lua
**Callback** **Callback**
```lua ```lua
@@ -31,7 +31,6 @@ When using SELECT, the return value will match `fetchAll, fetchSingle, or fetchS
-- Alias: exports.oxmysql:prepare_async -- Alias: exports.oxmysql:prepare_async
-- Alias: MySQL.Sync.prepare -- Alias: MySQL.Sync.prepare
CreateThread(function() CreateThread(function()
local result = MySQL.prepare.await('SELECT * FROM users WHERE identifier = ?', {playerIdentifier}) local result = MySQL.prepare.await('SELECT * FROM users WHERE identifier = ?', {playerIdentifier})
if result then if result then
@@ -42,7 +41,7 @@ When using SELECT, the return value will match `fetchAll, fetchSingle, or fetchS
end) end)
``` ```
=== "JavaScript" JavaScript
**Callback** **Callback**
```js ```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. 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 -3
View File
@@ -4,8 +4,8 @@ title: query
Generic function that can be utilised for any 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. When selecting data it will return all matching rows and columns, otherwise it will return field data such as insertid, affectedRows, etc.
!!! info "Example" :::info Example
=== "Lua" Lua
**Callback** **Callback**
```lua ```lua
@@ -35,7 +35,7 @@ When selecting data it will return all matching rows and columns, otherwise it w
end) end)
``` ```
=== "JavaScript" JavaScript
**Callback** **Callback**
```js ```js
@@ -58,3 +58,4 @@ When selecting data it will return all matching rows and columns, otherwise it w
} }
})() })()
``` ```
:::
+4 -3
View File
@@ -3,8 +3,8 @@ title: scalar
--- ---
Returns the first column for a single row. Returns the first column for a single row.
!!! info "Example" :::info Example
=== "Lua" Lua
**Callback** **Callback**
```lua ```lua
@@ -26,7 +26,7 @@ Returns the first column for a single row.
end) end)
``` ```
=== "JavaScript" JavaScript
**Callback** **Callback**
```js ```js
@@ -41,3 +41,4 @@ Returns the first column for a single row.
console.log(firstname) console.log(firstname)
})() })()
``` ```
:::
+4 -3
View File
@@ -3,8 +3,8 @@ title: single
--- ---
Returns the columns for a single row. Returns the columns for a single row.
!!! info "Example" :::info Example
=== "Lua" Lua
**Callback** **Callback**
```lua ```lua
@@ -30,7 +30,7 @@ Returns the columns for a single row.
end) end)
``` ```
=== "JavaScript" JavaScript
**Callback** **Callback**
```js ```js
@@ -47,3 +47,4 @@ Returns the columns for a single row.
console.log(result.identifier, result.firstname, result.lastname) console.log(result.identifier, result.firstname, result.lastname)
}) })
``` ```
:::
+4 -3
View File
@@ -3,8 +3,8 @@ title: update
--- ---
Returns the number of affected rows by the query. Returns the number of affected rows by the query.
!!! info "Example" :::info Example
=== "Lua" Lua
**Callback** **Callback**
```lua ```lua
@@ -30,7 +30,7 @@ Returns the number of affected rows by the query.
end) end)
``` ```
=== "JavaScript" JavaScript
**Callback** **Callback**
```js ```js
@@ -47,3 +47,4 @@ Returns the number of affected rows by the query.
console.log(affectedRows) console.log(affectedRows)
}) })
``` ```
:::