mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-04 06:28:53 +00:00
chore: Update Discord link
Also add note about named placeholders being deprecated.
This commit is contained in:
1 parent
86e51e79ef
commit
8874adc877
1 file changed
+16
-16
@@ -1,7 +1,7 @@
|
|||||||
<h1 align='center'><a href='https://overextended.github.io/oxmysql/'>Documentation</a></h2>
|
<h1 align='center'><a href='https://overextended.github.io/oxmysql/'>Documentation</a></h2>
|
||||||
|
|
||||||
|
|
||||||
### Introduction
|
### Introduction
|
||||||
|
|
||||||
Oxmysql is an alternative to the unmaintained mysql-async/ghmattimysql resources, utilising [node-mysql2](https://github.com/sidorares/node-mysql2) rather than [mysqljs](https://github.com/mysqljs/mysql).
|
Oxmysql is an alternative to the unmaintained mysql-async/ghmattimysql resources, utilising [node-mysql2](https://github.com/sidorares/node-mysql2) rather than [mysqljs](https://github.com/mysqljs/mysql).
|
||||||
|
|
||||||
As of v1.9.0 the preferred method of utilising oxmysql is via lib/MySQL, which can be loaded by adding `@oxmysql/lib/MySQL.lua` to your resource manifests. This resource should be 100% backwards compatible with mysql-async functionality on top of providing newer export wrappers and functionality.
|
As of v1.9.0 the preferred method of utilising oxmysql is via lib/MySQL, which can be loaded by adding `@oxmysql/lib/MySQL.lua` to your resource manifests. This resource should be 100% backwards compatible with mysql-async functionality on top of providing newer export wrappers and functionality.
|
||||||
@@ -9,6 +9,7 @@ As of v1.9.0 the preferred method of utilising oxmysql is via lib/MySQL, which c
|
|||||||
Refer to [issue #77](https://github.com/overextended/oxmysql/issues/77) for information on replacing your queries from older versions of oxmysql or ghmattimysql.
|
Refer to [issue #77](https://github.com/overextended/oxmysql/issues/77) for information on replacing your queries from older versions of oxmysql or ghmattimysql.
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
- Support for URI connection strings and semicolon separated values
|
- Support for URI connection strings and semicolon separated values
|
||||||
- Asynchronous queries utilising mysql2/promises connection pool
|
- Asynchronous queries utilising mysql2/promises connection pool
|
||||||
- Javascript async_retval exports supports promises across resources and runtimes
|
- Javascript async_retval exports supports promises across resources and runtimes
|
||||||
@@ -18,6 +19,7 @@ Refer to [issue #77](https://github.com/overextended/oxmysql/issues/77) for info
|
|||||||
- Support mysql-async syntax while providing newer (more accurate) names
|
- Support mysql-async syntax while providing newer (more accurate) names
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- Lua
|
-- Lua
|
||||||
MySQL.query('SELECT * from users WHERE identifier = ?', {identifier}), function(result)
|
MySQL.query('SELECT * from users WHERE identifier = ?', {identifier}), function(result)
|
||||||
@@ -30,22 +32,24 @@ CreateThread(function()
|
|||||||
-- same as MySQL.Sync.fetchAll
|
-- same as MySQL.Sync.fetchAll
|
||||||
end)
|
end)
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// JS
|
// JS
|
||||||
exports.oxmysql.query('SELECT * from users WHERE identifier = ?', [identifier], (result) => {
|
exports.oxmysql.query('SELECT * from users WHERE identifier = ?', [identifier], (result) => {
|
||||||
// callback response
|
// callback response
|
||||||
})
|
})(async () => {
|
||||||
(async() => {
|
const result = await exports.oxmysql.query_async('SELECT * from users WHERE identifier = ?', [identifier]);
|
||||||
const result = await exports.oxmysql.query_async('SELECT * from users WHERE identifier = ?', [identifier])
|
// await a promise to resolve
|
||||||
// await a promise to resolve
|
})();
|
||||||
})()
|
|
||||||
exports.oxmysql.query_async('SELECT * from users WHERE identifier = ?', [identifier]).then((result) => {
|
exports.oxmysql.query_async('SELECT * from users WHERE identifier = ?', [identifier]).then((result) => {
|
||||||
// utilise .then to resolve a promise like a callback
|
// utilise .then to resolve a promise like a callback
|
||||||
})
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
For more information regarding the use of queries, refer to the documentation linked above.
|
For more information regarding the use of queries, refer to the documentation linked above.
|
||||||
|
|
||||||
### Placeholders
|
### Placeholders
|
||||||
|
|
||||||
This allows queries to be properly prepared and escaped; the following lines are equivalent.
|
This allows queries to be properly prepared and escaped; the following lines are equivalent.
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -53,15 +57,11 @@ This allows queries to be properly prepared and escaped; the following lines are
|
|||||||
"SELECT group FROM users WHERE identifier = :identifier", {identifier = identifier}
|
"SELECT group FROM users WHERE identifier = :identifier", {identifier = identifier}
|
||||||
"SELECT group FROM users WHERE identifier = @identifier", {['@identifier'] = identifier}
|
"SELECT group FROM users WHERE identifier = @identifier", {['@identifier'] = identifier}
|
||||||
```
|
```
|
||||||
You can also use the following syntax when you are uncertain about the column to select.
|
|
||||||
```
|
|
||||||
"SELECT ?? FROM users WHERE identifier = ?", {column, identifier}
|
|
||||||
instead of using
|
|
||||||
"SELECT "..column.." FROM users WHERE identifier = ?", {identifier}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
Named placeholders are deprecated and should be avoided as much as possible.
|
||||||
|
|
||||||
<br><br><br><br><br>
|
<br><br><br><br><br>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
<p align='center'><a href='https://discord.io/overextended'>Discord</a></p>
|
<p align='center'><a href='https://discord.gg/overextended'>Discord</a></p>
|
||||||
<hr>
|
<hr>
|
||||||
Reference in new issue
Block a user