mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-02 06:28:54 +00:00
formatting and typos
This commit is contained in:
1 parent
75698216e0
commit
724c7e356d
99 files changed
+515
-305
No files matched your search
@@ -1,16 +1,19 @@
|
||||
# Benchmark
|
||||
|
||||
Internal benchmark
|
||||
```
|
||||
|
||||
```md
|
||||
Low: 0.1222ms | Avg: 0.14188357ms | Total: 1418.8357ms (10000 queries)
|
||||
```
|
||||
|
||||
Round-trip-time for exports
|
||||
```
|
||||
|
||||
```md
|
||||
Low: 0.1997ms | Avg: 0.25898800ms | Total: 2589.8800ms (10000 queries)
|
||||
```
|
||||
|
||||
#### Lua (5.4)
|
||||
## Lua (5.4)
|
||||
|
||||
```lua
|
||||
local val = 10000
|
||||
RegisterCommand('luasync', function()
|
||||
@@ -38,7 +41,8 @@ RegisterCommand('luasync', function()
|
||||
end)
|
||||
```
|
||||
|
||||
#### JavaScript
|
||||
## JavaScript
|
||||
|
||||
```js
|
||||
const val = 10000
|
||||
RegisterCommand('jssync', async() => {
|
||||
@@ -60,4 +64,4 @@ RegisterCommand('jssync', async() => {
|
||||
console.log(result)
|
||||
console.log('Low: '+ queryMsLow +'ms | Avg: '+averageQueryTime+'ms | Total: '+queryMsSum+'ms ('+queryTimesLocal.length+' queries)')
|
||||
})
|
||||
```
|
||||
```
|
||||
@@ -31,23 +31,21 @@ Reference the following for an idea of how to set your connection options.
|
||||
You must include one of the following lines, adjusted for your connection and database settings.
|
||||
|
||||
:::caution
|
||||
|
||||
When using convars do not replicate sensitive information to the client.
|
||||
When using convars do not replicate sensitive information to the client.
|
||||
**set** will only be set on the server, while **setr** is replicated.
|
||||
|
||||
:::
|
||||
|
||||
```
|
||||
```yaml
|
||||
set mysql_connection_string "mysql://root:12345@localhost:3306/es_extended?charset=utf8mb4"
|
||||
set mysql_connection_string "user=root;password=12345;host=localhost;port=3306;database=es_extended;charset=utf8mb4"
|
||||
```
|
||||
|
||||
Certain special characters are reserved or blocked and may cause issues when used in your password.
|
||||
Certain special characters are reserved or blocked and may cause issues when used in your password.
|
||||
For more optional settings (such as multiple statements) you can reference [pool.d.ts](https://github.com/sidorares/node-mysql2/blob/master/typings/mysql/lib/Pool.d.ts#L10) and [connection.d.ts](https://github.com/sidorares/node-mysql2/blob/master/typings/mysql/lib/Connection.d.ts#L8).
|
||||
|
||||
You can also add the following convars if you require extra information when testing queries.
|
||||
|
||||
```json
|
||||
```yaml
|
||||
set mysql_slow_query_warning 150
|
||||
set mysql_debug true
|
||||
```
|
||||
@@ -56,7 +54,7 @@ set mysql_debug true
|
||||
|
||||
When using the `mysql_debug` convar, rather than setting the value as true, you can send an array and enable debug prints for a set list of resources instead.
|
||||
|
||||
```json
|
||||
```yaml
|
||||
set mysql_debug [
|
||||
"ox_core",
|
||||
"ox_inventory"
|
||||
@@ -65,7 +63,7 @@ set mysql_debug [
|
||||
|
||||
This list can be adjusted during runtime with commands, temporarily adding or removing resources until the resource is restarted.
|
||||
|
||||
```
|
||||
```yaml
|
||||
oxmysql_debug remove ox_core
|
||||
oxmysql_debug add ox_core
|
||||
```
|
||||
@@ -74,7 +72,7 @@ oxmysql_debug add ox_core
|
||||
|
||||
Before using the UI first you have to make sure you have the `mysql_ui` convar set to true:
|
||||
|
||||
```json
|
||||
```yaml
|
||||
set mysql_ui true
|
||||
```
|
||||
|
||||
@@ -83,14 +81,14 @@ Also make sure that you have `command` ace permission access, then you should be
|
||||
|
||||
## Compatibility
|
||||
|
||||
You shouldn't run multiple mysql resources to ensure the best experience.
|
||||
You shouldn't run multiple mysql resources to ensure the best experience.
|
||||
The resources listed below can be deleted to allow oxmysql to handle the events, without any changes.
|
||||
|
||||
### mysql-async
|
||||
|
||||
Standard API for mysql-async uses `server_script '@mysql-async/lib/MySQL.lua'`.
|
||||
Standard API for mysql-async uses `server_script '@mysql-async/lib/MySQL.lua'`.
|
||||
Raw exports, mostly used in resources written in JavaScript or C#, are _not supported_.
|
||||
|
||||
### ghmattimysql
|
||||
|
||||
As of v2.4.0, oxmysql can be utilised with ghmattimysql's exports, such as `exports.ghmattimysql:execute`.
|
||||
As of v2.4.0, oxmysql can be utilised with ghmattimysql's exports, such as `exports.ghmattimysql:execute`.
|
||||
@@ -1,21 +1,24 @@
|
||||
# Common Issues
|
||||
|
||||
### Unable to establish a connection
|
||||
|
||||
This is usually the result of incorrect database settings or your password containing reserved characters (`; , / ? : @ & = + $ #`).
|
||||
:::tip Solution
|
||||
Ensure you have entered the correct database settings in the mysql_connection_string convar.
|
||||
Ensure you have entered the correct database settings in the mysql_connection_string convar.
|
||||
You can try using the semicolon-separated format if your password contains reserved characters.
|
||||
:::
|
||||
|
||||
### No such export ... in resource oxmysql
|
||||
|
||||
Typically the result of failing to follow instructions.
|
||||
:::tip Solution
|
||||
Download the latest release _build_ (not source) of oxmysql, and ensure it is starting before any resources that require it.
|
||||
:::
|
||||
|
||||
### Numbers treated as string
|
||||
|
||||
This is an incompatibility between mysqljs (used by mysql-async) and mysql2 (used by oxmysql) (See [Known incompatibilities with node-mysql](https://github.com/sidorares/node-mysql2/tree/master/documentation#known-incompatibilities-with-node-mysql))
|
||||
|
||||
To resolve this issue simply add `&decimalNumbers=true` to the connection string, ie. `mysql://root@localhost/essentialmode?charset=utf8mb4_general_ci&decimalNumbers=true` to revert to the behavior of mysqljs.
|
||||
|
||||
Do note with this that precision will be less with this, as Javascript treats all numbers as floats, so a double or decimal will be cast to a float this way.
|
||||
Do note with this that precision will be less with this, as Javascript treats all numbers as floats, so a double or decimal will be cast to a float this way.
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
This allows queries to be properly prepared and escaped; the following lines are equivalent.
|
||||
|
||||
```
|
||||
```lua
|
||||
"SELECT group FROM users WHERE identifier = ?", {identifier}
|
||||
"SELECT group FROM users WHERE identifier = :identifier", {identifier = identifier}
|
||||
"SELECT group FROM users WHERE identifier = @identifier", {['@identifier'] = identifier}
|
||||
|
||||
@@ -24,7 +24,7 @@ If you are using VSCode with [sumneko Lua](https://marketplace.visualstudio.com/
|
||||
|
||||
Use your favourite package manager to install our [node package](https://www.npmjs.com/package/@overextended/oxmysql).
|
||||
|
||||
```yaml
|
||||
```bash
|
||||
# With pnpm
|
||||
pnpm add @overextended/oxmysql
|
||||
|
||||
@@ -43,7 +43,7 @@ import { oxmysql as MySQL } from '@overextended/oxmysql';
|
||||
|
||||
## Placeholders
|
||||
|
||||
Safely format queries by using placeholders in the query, and sending arguments in an array or object.
|
||||
Safely format queries by using placeholders in the query, and sending arguments in an array or object.
|
||||
Named placeholders are not recommended, and unsupported when using MySQL.prepare.
|
||||
|
||||
```lua
|
||||
@@ -59,5 +59,5 @@ When uncertain if a row should be inserted into the database, or an existing row
|
||||
MySQL.prepare('INSERT INTO ox_inventory (owner, name, data) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE data = VALUES(data)', { owner, dbId, inventory })
|
||||
```
|
||||
|
||||
This is preferred over checking the existence of a row, then inserting or updating depending on the result.
|
||||
This is preferred over checking the existence of a row, then inserting or updating depending on the result.
|
||||
Furthermore, unlike using 'REPLACE INTO', the row is not deleted and re-inserted.
|
||||
@@ -5,6 +5,7 @@ Inserts a new entry into the database and returns the insert id for the row, if
|
||||
## Lua
|
||||
|
||||
### Callback
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:insert
|
||||
-- alias: MySQL.Async.insert
|
||||
@@ -15,6 +16,7 @@ end)
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:insert_async
|
||||
-- alias: MySQL.Sync.insert
|
||||
@@ -26,6 +28,7 @@ print(id)
|
||||
## JavaScript
|
||||
|
||||
### Callback
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.insert
|
||||
|
||||
@@ -35,6 +38,7 @@ MySQL.insert('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?,
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.insert_async
|
||||
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
# Prepare
|
||||
|
||||
The only function that provides true [prepared statements](https://github.com/sidorares/node-mysql2#using-prepared-statements), granting native protection and query planning by MySQL.
|
||||
Prepare can be used to execute frequently called queries faster and accepts multiple sets of parameters to be used with a single query.
|
||||
The only function that provides true [prepared statements](https://github.com/sidorares/node-mysql2#using-prepared-statements), granting native protection and query planning by MySQL.
|
||||
Prepare 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
|
||||
- You can only use `?` value placeholders, `??` column placeholders and named placeholders will throw an error
|
||||
|
||||
When using SELECT, the return value will match `query, single, or scalar` depending on the number of columns and rows selected.
|
||||
|
||||
## Lua
|
||||
|
||||
### Callback
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:prepare
|
||||
-- alias: MySQL.Async.prepare
|
||||
@@ -24,6 +25,7 @@ end)
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:prepare_async
|
||||
-- alias: MySQL.Sync.prepare
|
||||
@@ -37,6 +39,7 @@ end
|
||||
## JavaScript
|
||||
|
||||
### Callback
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.prepare
|
||||
|
||||
@@ -48,6 +51,7 @@ MySQL.prepare('SELECT * FROM users WHERE identifier = ?', [playerIdentifier], (r
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.prepare_async
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
# 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.
|
||||
|
||||
## Lua
|
||||
|
||||
### Callback
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:query
|
||||
-- alias: MySQL.Async.query
|
||||
@@ -18,7 +20,9 @@ MySQL.query('SELECT * FROM users WHERE identifier = ?', {playerIdentifier}, func
|
||||
end
|
||||
end)
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:query_async
|
||||
-- alias: MySQL.Sync.query
|
||||
@@ -35,6 +39,7 @@ end
|
||||
## JavaScript
|
||||
|
||||
### Callback
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.query
|
||||
|
||||
@@ -46,7 +51,9 @@ MySQL.query('SELECT * FROM users WHERE identifier = ?', [playerIdentifier], (res
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.query_async
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
# Scalar
|
||||
|
||||
Returns the first column for a single row.
|
||||
|
||||
## Lua
|
||||
|
||||
### Callback
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:scalar
|
||||
-- alias: MySQL.Async.fetchScalar
|
||||
@@ -14,6 +16,7 @@ end)
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:scalar_async
|
||||
-- alias: MySQL.Sync.fetchScalar
|
||||
@@ -25,6 +28,7 @@ print(firstname)
|
||||
## JavaScript
|
||||
|
||||
### Callback
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.scalar
|
||||
|
||||
@@ -34,6 +38,7 @@ MySQL.scalar('SELECT firstname FROM users WHERE identifier = ?', [playerIdentifi
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.scalar_async
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
# Single
|
||||
|
||||
Returns the columns for a single row.
|
||||
|
||||
## Lua
|
||||
|
||||
### Callback
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:single
|
||||
-- alias: MySQL.Async.fetchSingle
|
||||
@@ -16,6 +18,7 @@ end)
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:single_async
|
||||
-- alias: MySQL.Sync.fetchSingle
|
||||
@@ -29,6 +32,7 @@ end
|
||||
## JavaScript
|
||||
|
||||
### Callback
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.single
|
||||
|
||||
@@ -40,6 +44,7 @@ MySQL.single('SELECT * FROM users WHERE identifier = ?', [playerIdentifier],(row
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.single_async
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ console.log(success);
|
||||
|
||||
## Shared Format
|
||||
|
||||
When using the `Shared` format you must pass two parameters to the oxmysql export. The `queries` and the `parameters` those queries will use.
|
||||
When using the `Shared` format you must pass two parameters to the oxmysql export. The `queries` and the `parameters` those queries will use.
|
||||
This is useful if your queries use the same SQL variables.
|
||||
|
||||
### Lua
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
# Update
|
||||
|
||||
Returns the number of affected rows by the query.
|
||||
|
||||
## Lua
|
||||
|
||||
### Callback
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:update
|
||||
-- alias: MySQL.Async.execute
|
||||
@@ -16,6 +18,7 @@ end)
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```lua
|
||||
-- alias: exports.oxmysql:update_async
|
||||
-- alias: MySQL.Sync.execute
|
||||
@@ -29,6 +32,7 @@ end
|
||||
## JavaScript
|
||||
|
||||
### Callback
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.update
|
||||
|
||||
@@ -40,6 +44,7 @@ MySQL.update('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, p
|
||||
```
|
||||
|
||||
### Promise
|
||||
|
||||
```js
|
||||
// alias: exports.oxmysql.update_async
|
||||
|
||||
|
||||
Reference in new issue
Block a user