From f2781a008dc73dff4a766ef73f86ac8b778d4ed7 Mon Sep 17 00:00:00 2001 From: thelindat <65407488+thelindat@users.noreply.github.com> Date: Sun, 24 Oct 2021 16:48:54 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20overexte?= =?UTF-8?q?nded/oxmysql@2b40fafa7f5319ad3cc9eaa3777dde411563255f=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exports/execute/index.html | 76 ++++++------------------------------- exports/insert/index.html | 66 +++----------------------------- exports/scalar/index.html | 66 +++----------------------------- exports/single/index.html | 66 +++----------------------------- exports/update/index.html | 66 +++----------------------------- search/search_index.json | 2 +- sitemap.xml.gz | Bin 204 -> 204 bytes 7 files changed, 36 insertions(+), 306 deletions(-) diff --git a/exports/execute/index.html b/exports/execute/index.html index b4e7885..0ff202b 100644 --- a/exports/execute/index.html +++ b/exports/execute/index.html @@ -70,11 +70,6 @@
- - - Skip to content - -
@@ -352,59 +347,10 @@ - - Execute - - - @@ -520,7 +466,7 @@ When selecting data it will return all matching rows and columns, otherwise it w

Example

-

Async

+

Async

exports.oxmysql:execute('SELECT * FROM users WHERE identifier = ?', {playerIdentifier}, function(result)
     if result then
         for _, v in pairs(result) do
@@ -529,33 +475,33 @@ When selecting data it will return all matching rows and columns, otherwise it w
     end
 end)
 
-

Sync

+Sync
local result = exports.oxmysql:executeSync('SELECT * FROM users WHERE identifier = ?', {playerIdentifier})
 if result then
     for _, v in pairs(result) do
         print(v.identifier, v.firstname, v.lastname)
     end
 end
-
+

-

Async

+

Async

exports.oxmysql.execute('SELECT * FROM users WHERE identifier = ?', [playerIdentifier], function(result) {
-if (result) {
+  if (result) {
     result.forEach((v) => {
-    console.log(v.identifier, v.firstname, v.lastname)
+      console.log(v.identifier, v.firstname, v.lastname)
     })
-}
+  }
 })
 
-

Async

+Sync
const result = exports.oxmysql.executeSync('SELECT * FROM users WHERE identifier = ?', [playerIdentifier]) {
 if (result) {
-result.forEach((v) => {
+  result.forEach((v) => {
     console.log(v.identifier, v.firstname, v.lastname)
-})
+  })
 }
-
+

diff --git a/exports/insert/index.html b/exports/insert/index.html index c4551d3..d312fc1 100644 --- a/exports/insert/index.html +++ b/exports/insert/index.html @@ -70,11 +70,6 @@
- - - Skip to content - -
@@ -366,59 +361,10 @@ - - Insert - - - @@ -519,32 +465,32 @@

Example

-

Async

+

Async

exports.oxmysql:insert('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ', {playerIdentifier, firstName, lastName}, function(id)
     if id then
         print(id)
     end
 end)
 
-

Sync

+Sync
local id = exports.oxmysql:insertSync('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ', {playerIdentifier, firstName, lastName})
 if id then
     print(id)
 end
-
+

-

Async

+

Async

exports.oxmysql.insert('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ', [playerIdentifier, firstName, lastName], function(id) {
   if (id)
     console.log(id)
 })
 
-

Sync

+Sync
const id = exports.oxmysql.insertSync('INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ', [playerIdentifier, firstName, lastName]) {
 if (id)
   console.log(id)
-
+

diff --git a/exports/scalar/index.html b/exports/scalar/index.html index dea64da..8840e4a 100644 --- a/exports/scalar/index.html +++ b/exports/scalar/index.html @@ -70,11 +70,6 @@
- - - Skip to content - -
@@ -394,59 +389,10 @@ - - Scalar - - - @@ -519,32 +465,32 @@

Example

-

Async

+

Async

exports.oxmysql:scalar('SELECT firstname FROM users WHERE identifier = ?', {playerIdentifier}, function(result)
     if result then
         print(result.firstname)
     end
 end)
 
-

Sync

+Sync
local result = exports.oxmysql:scalarSync('SELECT firstname FROM users WHERE identifier = ?', {playerIdentifier})
 if result then
     print(result.firstname)
 end
-
+

-

Async

+

Async

exports.oxmysql.scalar('SELECT firstname FROM users WHERE identifier = ?', [playerIdentifier], function(result) {
   if (result)
     console.log(result.firstname)
 })
 
-

Sync

+Sync
const result = exports.oxmysql.scalarSync('SELECT firstname FROM users WHERE identifier = ?', [playerIdentifier]) {
 if (result)
   console.log(result.firstname)
-
+

diff --git a/exports/single/index.html b/exports/single/index.html index e58d419..436fc14 100644 --- a/exports/single/index.html +++ b/exports/single/index.html @@ -70,11 +70,6 @@
- - - Skip to content - -
@@ -408,59 +403,10 @@ - - Single - - - @@ -519,32 +465,32 @@

Example

-

Async

+

Async

exports.oxmysql:single('SELECT * FROM users WHERE identifier = ?', {playerIdentifier}, function(result)
     if result then
         print(result.identifier, result.firstname, result.lastname)
     end
 end)
 
-

Sync

+Sync
local result = exports.oxmysql:singleSync('SELECT * FROM users WHERE identifier = ?', {playerIdentifier})
 if result then
     print(result.identifier, result.firstname, result.lastname)
 end
-
+

-

Async

+

Async

exports.oxmysql.single('SELECT * FROM users WHERE identifier = ?', [playerIdentifier], function(result) {
   if (result)
     console.log(result.identifier, result.firstname, result.lastname)
 })
 
-

Sync

+Sync
const result = exports.oxmysql.singleSync('SELECT * FROM users WHERE identifier = ?', [playerIdentifier]) {
 if (result)
   console.log(result.identifier, result.firstname, result.lastname)
-
+

diff --git a/exports/update/index.html b/exports/update/index.html index 1dae7e8..3e36ab5 100644 --- a/exports/update/index.html +++ b/exports/update/index.html @@ -70,11 +70,6 @@
- - - Skip to content - -
@@ -436,59 +431,10 @@ - - Update - - - @@ -519,32 +465,32 @@

Example

-

Async

+

Async

exports.oxmysql:insert('UPDATE users SET firstname = ? WHERE identifier = ? ', {newName, playerIdentifier}, function(affectedRows)
     if affectedRows then
         print(affectedRows)
     end
 end)
 
-

Sync

+Sync
local id = exports.oxmysql:insertSync('UPDATE users SET firstname = ? WHERE identifier = ? ', {newName, playerIdentifier})
 if affectedRows then
     print(affectedRows)
 end
-
+

-

Async

+

Async

exports.oxmysql.insert('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier], function(affectedRows) {
   if (affectedRows)
     console.log(affectedRows)
 })
 
-

Sync

+Sync
const id = exports.oxmysql.insertSync('UPDATE users SET firstname = ? WHERE identifier = ? ', [newName, playerIdentifier]) {
 if (affectedRows)
   console.log(affectedRows)
-
+

diff --git a/search/search_index.json b/search/search_index.json index 857e931..3580fb7 100644 --- a/search/search_index.json +++ b/search/search_index.json @@ -1 +1 @@ -{"config":{"indexing":"full","lang":["en"],"min_search_length":3,"prebuild_index":false,"separator":"[\\s\\-]+"},"docs":[{"location":"","text":"Installation \u00b6 Download the latest build of oxmysql (not the source code). Extract the contents of the archive to your resources folder. Start the resource near the top of your resources in your server.cfg . If you have a lot of streamed assets, load them first to prevent timing out the connection. Configuration \u00b6 You can change the configuration settings by using convars inside your server.cfg . 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. set mysql_connection_string \"mysql://root:12345@localhost/es_extended?charset=utf8mb4\" set mysql_connection_string \"user=root;database=es_extended;password=12345;charset=utf8mb4\" You can also add the following convars if you require extra information when testing queries. set mysql_slow_query_warning 100 set mysql_debug true For more optional settings (such as multiple statements) you can reference pool.d.ts and connection.d.ts . Sync vs. async \u00b6 Asychronous behaviour does not truly exist in any of the scripting runtimes utilised, with tasks being performed as part of a queue each tick. Two variants of exports are provided for users, and their names describe their behaviour as part of the \"thread\" being executed. The following export is \"asynchronous\" and will execute in order, however the result will be delayed until a result is returned rather than pausing execution of following code. print ( 'This print will display first' ) exports . oxmysql : scalar ( 'SELECT group FROM users WHERE identifier = ?' , { playerIdentifier }, function ( result ) print ( 'Group: ' .. result ) end ) print ( 'This print will display second' ) Conversely, the following export will halt the active thread and wait for it to resolve before continuing. Furthermore, the result will be returned inline (left-hand assignment) rather than being locally scoped to the callback function. print ( 'This print will display first' ) local result = exports . oxmysql : scalarSync ( 'SELECT group FROM users WHERE identifier = ?' , { playerIdentifier }) print ( 'Group: ' .. result ) print ( 'This print will display third' ) Benchmark \u00b6 Lua: Low: 0.2955ms | High: 16.7566ms | Avg: 0.36956378ms | Total: 3695.6378ms (10000 queries) JS: Low: 0.2831ms | High: 5.1899ms | Avg: 0.33495788ms | Total: 3349.5788ms (10000 queries) These benchmark exports rather than actual query speed, resulting in extra delays due to serialisation and overhead. Lua generally falls slightly behind, but the amount is negligible. Furthermore we utilise the sync variants for this, so a query will only execute once the previous one has returned. Lua (5.4) \u00b6 local val = 10000 RegisterCommand ( 'luasync' , function () local queryTimesLocal = {} local result for i = 1 , val do local time = os . nanotime () local r = exports . oxmysql : scalarSync ( 'SELECT * from users' ) queryTimesLocal [ # queryTimesLocal + 1 ] = ( os . nanotime () - time ) / 1000000 if i == 1 then result = r end end local queryMsLow , queryMsHigh , queryMsSum = 1000 , 0 , 0 for _ , v in pairs ( queryTimesLocal ) do queryMsSum = queryMsSum + v end for _ , v in pairs ( queryTimesLocal ) do if v > queryMsHigh then queryMsHigh = v end end for _ , v in pairs ( queryTimesLocal ) do if v < queryMsLow then queryMsLow = v end end local averageQueryTime = queryMsSum / # queryTimesLocal print ( json . encode ( result )) print ( 'Low: ' .. queryMsLow .. 'ms | High: ' .. queryMsHigh .. 'ms | Avg: ' .. averageQueryTime .. 'ms | Total: ' .. queryMsSum .. 'ms (' ..# queryTimesLocal .. ' queries)' ) end ) JavaScript \u00b6 const val = 10000 RegisterCommand ( 'jssync' , async () => { const queryTimesLocal = []; let result for ( let i = 0 ; i < val ; i ++ ) { const startTime = process . hrtime . bigint () const r = await exports . oxmysql . scalarSync ( 'SELECT * from users' ) queryTimesLocal . push ( Number ( process . hrtime . bigint () - startTime ) / 1000000 ) if ( i === 0 ) result = 1 } const queryMsSum = queryTimesLocal . reduce (( a , b ) => a + b , 0 ) const queryMsHigh = queryTimesLocal . sort (( a , b ) => b - a )[ 0 ] const queryMsLow = queryTimesLocal . sort (( a , b ) => a - b )[ 0 ] const averageQueryTime = queryMsSum / queryTimesLocal . length console . log ( result ) console . log ( 'Low: ' + queryMsLow + 'ms | High: ' + queryMsHigh + 'ms | Avg: ' + averageQueryTime + 'ms | Total: ' + queryMsSum + 'ms (' + queryTimesLocal . length + ' queries)' ) })","title":"Getting Started"},{"location":"#installation","text":"Download the latest build of oxmysql (not the source code). Extract the contents of the archive to your resources folder. Start the resource near the top of your resources in your server.cfg . If you have a lot of streamed assets, load them first to prevent timing out the connection.","title":"Installation"},{"location":"#configuration","text":"You can change the configuration settings by using convars inside your server.cfg . 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. set mysql_connection_string \"mysql://root:12345@localhost/es_extended?charset=utf8mb4\" set mysql_connection_string \"user=root;database=es_extended;password=12345;charset=utf8mb4\" You can also add the following convars if you require extra information when testing queries. set mysql_slow_query_warning 100 set mysql_debug true For more optional settings (such as multiple statements) you can reference pool.d.ts and connection.d.ts .","title":"Configuration"},{"location":"#sync-vs-async","text":"Asychronous behaviour does not truly exist in any of the scripting runtimes utilised, with tasks being performed as part of a queue each tick. Two variants of exports are provided for users, and their names describe their behaviour as part of the \"thread\" being executed. The following export is \"asynchronous\" and will execute in order, however the result will be delayed until a result is returned rather than pausing execution of following code. print ( 'This print will display first' ) exports . oxmysql : scalar ( 'SELECT group FROM users WHERE identifier = ?' , { playerIdentifier }, function ( result ) print ( 'Group: ' .. result ) end ) print ( 'This print will display second' ) Conversely, the following export will halt the active thread and wait for it to resolve before continuing. Furthermore, the result will be returned inline (left-hand assignment) rather than being locally scoped to the callback function. print ( 'This print will display first' ) local result = exports . oxmysql : scalarSync ( 'SELECT group FROM users WHERE identifier = ?' , { playerIdentifier }) print ( 'Group: ' .. result ) print ( 'This print will display third' )","title":"Sync vs. async"},{"location":"#benchmark","text":"Lua: Low: 0.2955ms | High: 16.7566ms | Avg: 0.36956378ms | Total: 3695.6378ms (10000 queries) JS: Low: 0.2831ms | High: 5.1899ms | Avg: 0.33495788ms | Total: 3349.5788ms (10000 queries) These benchmark exports rather than actual query speed, resulting in extra delays due to serialisation and overhead. Lua generally falls slightly behind, but the amount is negligible. Furthermore we utilise the sync variants for this, so a query will only execute once the previous one has returned.","title":"Benchmark"},{"location":"#lua-54","text":"local val = 10000 RegisterCommand ( 'luasync' , function () local queryTimesLocal = {} local result for i = 1 , val do local time = os . nanotime () local r = exports . oxmysql : scalarSync ( 'SELECT * from users' ) queryTimesLocal [ # queryTimesLocal + 1 ] = ( os . nanotime () - time ) / 1000000 if i == 1 then result = r end end local queryMsLow , queryMsHigh , queryMsSum = 1000 , 0 , 0 for _ , v in pairs ( queryTimesLocal ) do queryMsSum = queryMsSum + v end for _ , v in pairs ( queryTimesLocal ) do if v > queryMsHigh then queryMsHigh = v end end for _ , v in pairs ( queryTimesLocal ) do if v < queryMsLow then queryMsLow = v end end local averageQueryTime = queryMsSum / # queryTimesLocal print ( json . encode ( result )) print ( 'Low: ' .. queryMsLow .. 'ms | High: ' .. queryMsHigh .. 'ms | Avg: ' .. averageQueryTime .. 'ms | Total: ' .. queryMsSum .. 'ms (' ..# queryTimesLocal .. ' queries)' ) end )","title":"Lua (5.4)"},{"location":"#javascript","text":"const val = 10000 RegisterCommand ( 'jssync' , async () => { const queryTimesLocal = []; let result for ( let i = 0 ; i < val ; i ++ ) { const startTime = process . hrtime . bigint () const r = await exports . oxmysql . scalarSync ( 'SELECT * from users' ) queryTimesLocal . push ( Number ( process . hrtime . bigint () - startTime ) / 1000000 ) if ( i === 0 ) result = 1 } const queryMsSum = queryTimesLocal . reduce (( a , b ) => a + b , 0 ) const queryMsHigh = queryTimesLocal . sort (( a , b ) => b - a )[ 0 ] const queryMsLow = queryTimesLocal . sort (( a , b ) => a - b )[ 0 ] const averageQueryTime = queryMsSum / queryTimesLocal . length console . log ( result ) console . log ( 'Low: ' + queryMsLow + 'ms | High: ' + queryMsHigh + 'ms | Avg: ' + averageQueryTime + 'ms | Total: ' + queryMsSum + 'ms (' + queryTimesLocal . length + ' queries)' ) })","title":"JavaScript"},{"location":"issues/","text":"Placeholder \u00b6 Integer faucibus justo neque. Vivamus vitae posuere tellus. Pellentesque aliquet semper nisi, sit amet pulvinar ligula viverra facilisis. Morbi lacus lacus, finibus quis hendrerit at, gravida quis arcu. Solution Proin imperdiet ipsum nisi, et ullamcorper tellus gravida quis. Proin at ipsum et tortor bibendum gravida.","title":"Common issues"},{"location":"issues/#placeholder","text":"Integer faucibus justo neque. Vivamus vitae posuere tellus. Pellentesque aliquet semper nisi, sit amet pulvinar ligula viverra facilisis. Morbi lacus lacus, finibus quis hendrerit at, gravida quis arcu. Solution Proin imperdiet ipsum nisi, et ullamcorper tellus gravida quis. Proin at ipsum et tortor bibendum gravida.","title":"Placeholder"},{"location":"exports/","text":"","title":"Index"},{"location":"exports/execute/","text":"Generic function that can be utilised for any query, synonymous with fetch. When selecting data it will return all matching rows and columns, otherwise it will return field data such as insertid, affectedRows, etc. Example Lua Async \u00b6 exports . oxmysql : execute ( 'SELECT * FROM users WHERE identifier = ?' , { playerIdentifier }, function ( result ) if result then for _ , v in pairs ( result ) do print ( v . identifier , v . firstname , v . lastname ) end end end ) Sync \u00b6 local result = exports . oxmysql : executeSync ( 'SELECT * FROM users WHERE identifier = ?' , { playerIdentifier }) if result then for _ , v in pairs ( result ) do print ( v . identifier , v . firstname , v . lastname ) end end JavaScript Async \u00b6 exports . oxmysql . execute ( 'SELECT * FROM users WHERE identifier = ?' , [ playerIdentifier ], function ( result ) { if ( result ) { result . forEach (( v ) => { console . log ( v . identifier , v . firstname , v . lastname ) }) } }) Async \u00b6 const result = exports . oxmysql . executeSync ( 'SELECT * FROM users WHERE identifier = ?' , [ playerIdentifier ]) { if ( result ) { result . forEach (( v ) => { console . log ( v . identifier , v . firstname , v . lastname ) }) }","title":"Execute"},{"location":"exports/execute/#async","text":"exports . oxmysql : execute ( 'SELECT * FROM users WHERE identifier = ?' , { playerIdentifier }, function ( result ) if result then for _ , v in pairs ( result ) do print ( v . identifier , v . firstname , v . lastname ) end end end )","title":"Async"},{"location":"exports/execute/#sync","text":"local result = exports . oxmysql : executeSync ( 'SELECT * FROM users WHERE identifier = ?' , { playerIdentifier }) if result then for _ , v in pairs ( result ) do print ( v . identifier , v . firstname , v . lastname ) end end JavaScript","title":"Sync"},{"location":"exports/execute/#async_1","text":"exports . oxmysql . execute ( 'SELECT * FROM users WHERE identifier = ?' , [ playerIdentifier ], function ( result ) { if ( result ) { result . forEach (( v ) => { console . log ( v . identifier , v . firstname , v . lastname ) }) } })","title":"Async"},{"location":"exports/execute/#async_2","text":"const result = exports . oxmysql . executeSync ( 'SELECT * FROM users WHERE identifier = ?' , [ playerIdentifier ]) { if ( result ) { result . forEach (( v ) => { console . log ( v . identifier , v . firstname , v . lastname ) }) }","title":"Async"},{"location":"exports/insert/","text":"Inserts a new entry into the database and returns the insert id for the row, if valid. Example Lua Async \u00b6 exports . oxmysql : insert ( 'INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ' , { playerIdentifier , firstName , lastName }, function ( id ) if id then print ( id ) end end ) Sync \u00b6 local id = exports . oxmysql : insertSync ( 'INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ' , { playerIdentifier , firstName , lastName }) if id then print ( id ) end JavaScript Async \u00b6 exports . oxmysql . insert ( 'INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ' , [ playerIdentifier , firstName , lastName ], function ( id ) { if ( id ) console . log ( id ) }) Sync \u00b6 const id = exports . oxmysql . insertSync ( 'INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ' , [ playerIdentifier , firstName , lastName ]) { if ( id ) console . log ( id )","title":"Insert"},{"location":"exports/insert/#async","text":"exports . oxmysql : insert ( 'INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ' , { playerIdentifier , firstName , lastName }, function ( id ) if id then print ( id ) end end )","title":"Async"},{"location":"exports/insert/#sync","text":"local id = exports . oxmysql : insertSync ( 'INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ' , { playerIdentifier , firstName , lastName }) if id then print ( id ) end JavaScript","title":"Sync"},{"location":"exports/insert/#async_1","text":"exports . oxmysql . insert ( 'INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ' , [ playerIdentifier , firstName , lastName ], function ( id ) { if ( id ) console . log ( id ) })","title":"Async"},{"location":"exports/insert/#sync_1","text":"const id = exports . oxmysql . insertSync ( 'INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ' , [ playerIdentifier , firstName , lastName ]) { if ( id ) console . log ( id )","title":"Sync"},{"location":"exports/prepare/","text":"TODO","title":"Prepare"},{"location":"exports/scalar/","text":"Returns the first column for a single row. Example Lua Async \u00b6 exports . oxmysql : scalar ( 'SELECT firstname FROM users WHERE identifier = ?' , { playerIdentifier }, function ( result ) if result then print ( result . firstname ) end end ) Sync \u00b6 local result = exports . oxmysql : scalarSync ( 'SELECT firstname FROM users WHERE identifier = ?' , { playerIdentifier }) if result then print ( result . firstname ) end JavaScript Async \u00b6 exports . oxmysql . scalar ( 'SELECT firstname FROM users WHERE identifier = ?' , [ playerIdentifier ], function ( result ) { if ( result ) console . log ( result . firstname ) }) Sync \u00b6 const result = exports . oxmysql . scalarSync ( 'SELECT firstname FROM users WHERE identifier = ?' , [ playerIdentifier ]) { if ( result ) console . log ( result . firstname )","title":"Scalar"},{"location":"exports/scalar/#async","text":"exports . oxmysql : scalar ( 'SELECT firstname FROM users WHERE identifier = ?' , { playerIdentifier }, function ( result ) if result then print ( result . firstname ) end end )","title":"Async"},{"location":"exports/scalar/#sync","text":"local result = exports . oxmysql : scalarSync ( 'SELECT firstname FROM users WHERE identifier = ?' , { playerIdentifier }) if result then print ( result . firstname ) end JavaScript","title":"Sync"},{"location":"exports/scalar/#async_1","text":"exports . oxmysql . scalar ( 'SELECT firstname FROM users WHERE identifier = ?' , [ playerIdentifier ], function ( result ) { if ( result ) console . log ( result . firstname ) })","title":"Async"},{"location":"exports/scalar/#sync_1","text":"const result = exports . oxmysql . scalarSync ( 'SELECT firstname FROM users WHERE identifier = ?' , [ playerIdentifier ]) { if ( result ) console . log ( result . firstname )","title":"Sync"},{"location":"exports/single/","text":"Returns the columns for a single row. Example Lua Async \u00b6 exports . oxmysql : single ( 'SELECT * FROM users WHERE identifier = ?' , { playerIdentifier }, function ( result ) if result then print ( result . identifier , result . firstname , result . lastname ) end end ) Sync \u00b6 local result = exports . oxmysql : singleSync ( 'SELECT * FROM users WHERE identifier = ?' , { playerIdentifier }) if result then print ( result . identifier , result . firstname , result . lastname ) end JavaScript Async \u00b6 exports . oxmysql . single ( 'SELECT * FROM users WHERE identifier = ?' , [ playerIdentifier ], function ( result ) { if ( result ) console . log ( result . identifier , result . firstname , result . lastname ) }) Sync \u00b6 const result = exports . oxmysql . singleSync ( 'SELECT * FROM users WHERE identifier = ?' , [ playerIdentifier ]) { if ( result ) console . log ( result . identifier , result . firstname , result . lastname )","title":"Single"},{"location":"exports/single/#async","text":"exports . oxmysql : single ( 'SELECT * FROM users WHERE identifier = ?' , { playerIdentifier }, function ( result ) if result then print ( result . identifier , result . firstname , result . lastname ) end end )","title":"Async"},{"location":"exports/single/#sync","text":"local result = exports . oxmysql : singleSync ( 'SELECT * FROM users WHERE identifier = ?' , { playerIdentifier }) if result then print ( result . identifier , result . firstname , result . lastname ) end JavaScript","title":"Sync"},{"location":"exports/single/#async_1","text":"exports . oxmysql . single ( 'SELECT * FROM users WHERE identifier = ?' , [ playerIdentifier ], function ( result ) { if ( result ) console . log ( result . identifier , result . firstname , result . lastname ) })","title":"Async"},{"location":"exports/single/#sync_1","text":"const result = exports . oxmysql . singleSync ( 'SELECT * FROM users WHERE identifier = ?' , [ playerIdentifier ]) { if ( result ) console . log ( result . identifier , result . firstname , result . lastname )","title":"Sync"},{"location":"exports/transaction/","text":"Transactions \u00b6 A transaction executes multiple queries and commits them only if all succeed. If one fails, none of the queries are committed. The return value is a boolean , which is the result of the transaction. Specific Format \u00b6 When using the Specific format you must pass one parameter to the oxmysql export. In this case, the queries parameter contains your queries and the SQL variables unique to each query. This is useful for transactions where the queries do not share many SQL variables. Usage \u00b6 Lua local queries = { { query = 'INSERT INTO `test` (id) VALUES (:someid)' , values = { [ 'someid' ] = 1 } }, { query = 'INSERT INTO `test` (id) VALUES (:someid)' , values = { [ 'someid' ] = 2 } } } -- NOTE, the 'values' tables can be named 'parameters' here for MySQL-Async compatibility. -- Async exports . oxmysql : transaction ( queries , function ( result ) print ( result ) end ) -- Sync local result = exports . oxmysql : transactionSync ( queries ) print ( result ) JavaScript const queries = [ { query = 'INSERT INTO `test` (id) VALUES (:someid)' , values = { someid = 1 } }, { query = 'INSERT INTO `test` (id) VALUES (:someid)' , values = { someid = 2 } } ] // NOTE, the 'values' objects can be named 'parameters' here for MySQL-Async compatibility. // Async exports . oxmysql . transaction ( queries , ( result ) => { console . log ( result ) }) // Sync const result = await exports . oxmysql . transactionSync ( queries ) console . log ( result ) Shared Format \u00b6 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 local queries = { 'INSERT INTO `test` (id, name) VALUES (:someid, :somename)' , 'SET `name` = :newname IN `test` WHERE `id` = :someid' } local parameters = { [ 'someid' ] = 2 , [ 'somename' ] = 'John Doe' , [ 'newname' ] = 'John Notdoe' } -- Async exports . oxmysql : transaction ( queries , parameters , function ( result ) print ( result ) end ) -- Sync local result = exports . oxmysql : transactionSync ( queries , parameters ) print ( result ) JavaScript const queries = [ 'INSERT INTO `test` (id, name) VALUES (:someid, :somename)' , 'SET `name` = :newname IN `test` WHERE `id` = :someid' ] const parameters = { someid = 2 , somename = 'John Doe' , newname = 'John Notdoe' } // Async exports . oxmysql . transaction ( queries , parameters , ( result ) => { console . log ( result ) }) // Sync const result = await exports . oxmysql . transactionSync ( queries , parameters ) console . log ( result ) Transaction Isolation Level \u00b6 This can be set through the convar mysql_transaction_isolation_level which should be an integer ranging from 1-4 . The default convar value set by oxmysql is 2 . Convar Value Result 1 Repeatable Read 2 Read Committed 3 Read Uncommitted 4 Serializable","title":"Transactions"},{"location":"exports/transaction/#transactions","text":"A transaction executes multiple queries and commits them only if all succeed. If one fails, none of the queries are committed. The return value is a boolean , which is the result of the transaction.","title":"Transactions"},{"location":"exports/transaction/#specific-format","text":"When using the Specific format you must pass one parameter to the oxmysql export. In this case, the queries parameter contains your queries and the SQL variables unique to each query. This is useful for transactions where the queries do not share many SQL variables.","title":"Specific Format"},{"location":"exports/transaction/#usage","text":"Lua local queries = { { query = 'INSERT INTO `test` (id) VALUES (:someid)' , values = { [ 'someid' ] = 1 } }, { query = 'INSERT INTO `test` (id) VALUES (:someid)' , values = { [ 'someid' ] = 2 } } } -- NOTE, the 'values' tables can be named 'parameters' here for MySQL-Async compatibility. -- Async exports . oxmysql : transaction ( queries , function ( result ) print ( result ) end ) -- Sync local result = exports . oxmysql : transactionSync ( queries ) print ( result ) JavaScript const queries = [ { query = 'INSERT INTO `test` (id) VALUES (:someid)' , values = { someid = 1 } }, { query = 'INSERT INTO `test` (id) VALUES (:someid)' , values = { someid = 2 } } ] // NOTE, the 'values' objects can be named 'parameters' here for MySQL-Async compatibility. // Async exports . oxmysql . transaction ( queries , ( result ) => { console . log ( result ) }) // Sync const result = await exports . oxmysql . transactionSync ( queries ) console . log ( result )","title":"Usage"},{"location":"exports/transaction/#shared-format","text":"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 local queries = { 'INSERT INTO `test` (id, name) VALUES (:someid, :somename)' , 'SET `name` = :newname IN `test` WHERE `id` = :someid' } local parameters = { [ 'someid' ] = 2 , [ 'somename' ] = 'John Doe' , [ 'newname' ] = 'John Notdoe' } -- Async exports . oxmysql : transaction ( queries , parameters , function ( result ) print ( result ) end ) -- Sync local result = exports . oxmysql : transactionSync ( queries , parameters ) print ( result ) JavaScript const queries = [ 'INSERT INTO `test` (id, name) VALUES (:someid, :somename)' , 'SET `name` = :newname IN `test` WHERE `id` = :someid' ] const parameters = { someid = 2 , somename = 'John Doe' , newname = 'John Notdoe' } // Async exports . oxmysql . transaction ( queries , parameters , ( result ) => { console . log ( result ) }) // Sync const result = await exports . oxmysql . transactionSync ( queries , parameters ) console . log ( result )","title":"Shared Format"},{"location":"exports/transaction/#transaction-isolation-level","text":"This can be set through the convar mysql_transaction_isolation_level which should be an integer ranging from 1-4 . The default convar value set by oxmysql is 2 . Convar Value Result 1 Repeatable Read 2 Read Committed 3 Read Uncommitted 4 Serializable","title":"Transaction Isolation Level"},{"location":"exports/update/","text":"Updates an entry in the database and returns the number of affected rows. Example Lua Async \u00b6 exports . oxmysql : insert ( 'UPDATE users SET firstname = ? WHERE identifier = ? ' , { newName , playerIdentifier }, function ( affectedRows ) if affectedRows then print ( affectedRows ) end end ) Sync \u00b6 local id = exports . oxmysql : insertSync ( 'UPDATE users SET firstname = ? WHERE identifier = ? ' , { newName , playerIdentifier }) if affectedRows then print ( affectedRows ) end JavaScript Async \u00b6 exports . oxmysql . insert ( 'UPDATE users SET firstname = ? WHERE identifier = ? ' , [ newName , playerIdentifier ], function ( affectedRows ) { if ( affectedRows ) console . log ( affectedRows ) }) Sync \u00b6 const id = exports . oxmysql . insertSync ( 'UPDATE users SET firstname = ? WHERE identifier = ? ' , [ newName , playerIdentifier ]) { if ( affectedRows ) console . log ( affectedRows )","title":"Update"},{"location":"exports/update/#async","text":"exports . oxmysql : insert ( 'UPDATE users SET firstname = ? WHERE identifier = ? ' , { newName , playerIdentifier }, function ( affectedRows ) if affectedRows then print ( affectedRows ) end end )","title":"Async"},{"location":"exports/update/#sync","text":"local id = exports . oxmysql : insertSync ( 'UPDATE users SET firstname = ? WHERE identifier = ? ' , { newName , playerIdentifier }) if affectedRows then print ( affectedRows ) end JavaScript","title":"Sync"},{"location":"exports/update/#async_1","text":"exports . oxmysql . insert ( 'UPDATE users SET firstname = ? WHERE identifier = ? ' , [ newName , playerIdentifier ], function ( affectedRows ) { if ( affectedRows ) console . log ( affectedRows ) })","title":"Async"},{"location":"exports/update/#sync_1","text":"const id = exports . oxmysql . insertSync ( 'UPDATE users SET firstname = ? WHERE identifier = ? ' , [ newName , playerIdentifier ]) { if ( affectedRows ) console . log ( affectedRows )","title":"Sync"}]} \ No newline at end of file +{"config":{"indexing":"full","lang":["en"],"min_search_length":3,"prebuild_index":false,"separator":"[\\s\\-]+"},"docs":[{"location":"","text":"Installation \u00b6 Download the latest build of oxmysql (not the source code). Extract the contents of the archive to your resources folder. Start the resource near the top of your resources in your server.cfg . If you have a lot of streamed assets, load them first to prevent timing out the connection. Configuration \u00b6 You can change the configuration settings by using convars inside your server.cfg . 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. set mysql_connection_string \"mysql://root:12345@localhost/es_extended?charset=utf8mb4\" set mysql_connection_string \"user=root;database=es_extended;password=12345;charset=utf8mb4\" You can also add the following convars if you require extra information when testing queries. set mysql_slow_query_warning 100 set mysql_debug true For more optional settings (such as multiple statements) you can reference pool.d.ts and connection.d.ts . Sync vs. async \u00b6 Asychronous behaviour does not truly exist in any of the scripting runtimes utilised, with tasks being performed as part of a queue each tick. Two variants of exports are provided for users, and their names describe their behaviour as part of the \"thread\" being executed. The following export is \"asynchronous\" and will execute in order, however the result will be delayed until a result is returned rather than pausing execution of following code. print ( 'This print will display first' ) exports . oxmysql : scalar ( 'SELECT group FROM users WHERE identifier = ?' , { playerIdentifier }, function ( result ) print ( 'Group: ' .. result ) end ) print ( 'This print will display second' ) Conversely, the following export will halt the active thread and wait for it to resolve before continuing. Furthermore, the result will be returned inline (left-hand assignment) rather than being locally scoped to the callback function. print ( 'This print will display first' ) local result = exports . oxmysql : scalarSync ( 'SELECT group FROM users WHERE identifier = ?' , { playerIdentifier }) print ( 'Group: ' .. result ) print ( 'This print will display third' ) Benchmark \u00b6 Lua: Low: 0.2955ms | High: 16.7566ms | Avg: 0.36956378ms | Total: 3695.6378ms (10000 queries) JS: Low: 0.2831ms | High: 5.1899ms | Avg: 0.33495788ms | Total: 3349.5788ms (10000 queries) These benchmark exports rather than actual query speed, resulting in extra delays due to serialisation and overhead. Lua generally falls slightly behind, but the amount is negligible. Furthermore we utilise the sync variants for this, so a query will only execute once the previous one has returned. Lua (5.4) \u00b6 local val = 10000 RegisterCommand ( 'luasync' , function () local queryTimesLocal = {} local result for i = 1 , val do local time = os . nanotime () local r = exports . oxmysql : scalarSync ( 'SELECT * from users' ) queryTimesLocal [ # queryTimesLocal + 1 ] = ( os . nanotime () - time ) / 1000000 if i == 1 then result = r end end local queryMsLow , queryMsHigh , queryMsSum = 1000 , 0 , 0 for _ , v in pairs ( queryTimesLocal ) do queryMsSum = queryMsSum + v end for _ , v in pairs ( queryTimesLocal ) do if v > queryMsHigh then queryMsHigh = v end end for _ , v in pairs ( queryTimesLocal ) do if v < queryMsLow then queryMsLow = v end end local averageQueryTime = queryMsSum / # queryTimesLocal print ( json . encode ( result )) print ( 'Low: ' .. queryMsLow .. 'ms | High: ' .. queryMsHigh .. 'ms | Avg: ' .. averageQueryTime .. 'ms | Total: ' .. queryMsSum .. 'ms (' ..# queryTimesLocal .. ' queries)' ) end ) JavaScript \u00b6 const val = 10000 RegisterCommand ( 'jssync' , async () => { const queryTimesLocal = []; let result for ( let i = 0 ; i < val ; i ++ ) { const startTime = process . hrtime . bigint () const r = await exports . oxmysql . scalarSync ( 'SELECT * from users' ) queryTimesLocal . push ( Number ( process . hrtime . bigint () - startTime ) / 1000000 ) if ( i === 0 ) result = 1 } const queryMsSum = queryTimesLocal . reduce (( a , b ) => a + b , 0 ) const queryMsHigh = queryTimesLocal . sort (( a , b ) => b - a )[ 0 ] const queryMsLow = queryTimesLocal . sort (( a , b ) => a - b )[ 0 ] const averageQueryTime = queryMsSum / queryTimesLocal . length console . log ( result ) console . log ( 'Low: ' + queryMsLow + 'ms | High: ' + queryMsHigh + 'ms | Avg: ' + averageQueryTime + 'ms | Total: ' + queryMsSum + 'ms (' + queryTimesLocal . length + ' queries)' ) })","title":"Getting Started"},{"location":"#installation","text":"Download the latest build of oxmysql (not the source code). Extract the contents of the archive to your resources folder. Start the resource near the top of your resources in your server.cfg . If you have a lot of streamed assets, load them first to prevent timing out the connection.","title":"Installation"},{"location":"#configuration","text":"You can change the configuration settings by using convars inside your server.cfg . 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. set mysql_connection_string \"mysql://root:12345@localhost/es_extended?charset=utf8mb4\" set mysql_connection_string \"user=root;database=es_extended;password=12345;charset=utf8mb4\" You can also add the following convars if you require extra information when testing queries. set mysql_slow_query_warning 100 set mysql_debug true For more optional settings (such as multiple statements) you can reference pool.d.ts and connection.d.ts .","title":"Configuration"},{"location":"#sync-vs-async","text":"Asychronous behaviour does not truly exist in any of the scripting runtimes utilised, with tasks being performed as part of a queue each tick. Two variants of exports are provided for users, and their names describe their behaviour as part of the \"thread\" being executed. The following export is \"asynchronous\" and will execute in order, however the result will be delayed until a result is returned rather than pausing execution of following code. print ( 'This print will display first' ) exports . oxmysql : scalar ( 'SELECT group FROM users WHERE identifier = ?' , { playerIdentifier }, function ( result ) print ( 'Group: ' .. result ) end ) print ( 'This print will display second' ) Conversely, the following export will halt the active thread and wait for it to resolve before continuing. Furthermore, the result will be returned inline (left-hand assignment) rather than being locally scoped to the callback function. print ( 'This print will display first' ) local result = exports . oxmysql : scalarSync ( 'SELECT group FROM users WHERE identifier = ?' , { playerIdentifier }) print ( 'Group: ' .. result ) print ( 'This print will display third' )","title":"Sync vs. async"},{"location":"#benchmark","text":"Lua: Low: 0.2955ms | High: 16.7566ms | Avg: 0.36956378ms | Total: 3695.6378ms (10000 queries) JS: Low: 0.2831ms | High: 5.1899ms | Avg: 0.33495788ms | Total: 3349.5788ms (10000 queries) These benchmark exports rather than actual query speed, resulting in extra delays due to serialisation and overhead. Lua generally falls slightly behind, but the amount is negligible. Furthermore we utilise the sync variants for this, so a query will only execute once the previous one has returned.","title":"Benchmark"},{"location":"#lua-54","text":"local val = 10000 RegisterCommand ( 'luasync' , function () local queryTimesLocal = {} local result for i = 1 , val do local time = os . nanotime () local r = exports . oxmysql : scalarSync ( 'SELECT * from users' ) queryTimesLocal [ # queryTimesLocal + 1 ] = ( os . nanotime () - time ) / 1000000 if i == 1 then result = r end end local queryMsLow , queryMsHigh , queryMsSum = 1000 , 0 , 0 for _ , v in pairs ( queryTimesLocal ) do queryMsSum = queryMsSum + v end for _ , v in pairs ( queryTimesLocal ) do if v > queryMsHigh then queryMsHigh = v end end for _ , v in pairs ( queryTimesLocal ) do if v < queryMsLow then queryMsLow = v end end local averageQueryTime = queryMsSum / # queryTimesLocal print ( json . encode ( result )) print ( 'Low: ' .. queryMsLow .. 'ms | High: ' .. queryMsHigh .. 'ms | Avg: ' .. averageQueryTime .. 'ms | Total: ' .. queryMsSum .. 'ms (' ..# queryTimesLocal .. ' queries)' ) end )","title":"Lua (5.4)"},{"location":"#javascript","text":"const val = 10000 RegisterCommand ( 'jssync' , async () => { const queryTimesLocal = []; let result for ( let i = 0 ; i < val ; i ++ ) { const startTime = process . hrtime . bigint () const r = await exports . oxmysql . scalarSync ( 'SELECT * from users' ) queryTimesLocal . push ( Number ( process . hrtime . bigint () - startTime ) / 1000000 ) if ( i === 0 ) result = 1 } const queryMsSum = queryTimesLocal . reduce (( a , b ) => a + b , 0 ) const queryMsHigh = queryTimesLocal . sort (( a , b ) => b - a )[ 0 ] const queryMsLow = queryTimesLocal . sort (( a , b ) => a - b )[ 0 ] const averageQueryTime = queryMsSum / queryTimesLocal . length console . log ( result ) console . log ( 'Low: ' + queryMsLow + 'ms | High: ' + queryMsHigh + 'ms | Avg: ' + averageQueryTime + 'ms | Total: ' + queryMsSum + 'ms (' + queryTimesLocal . length + ' queries)' ) })","title":"JavaScript"},{"location":"issues/","text":"Placeholder \u00b6 Integer faucibus justo neque. Vivamus vitae posuere tellus. Pellentesque aliquet semper nisi, sit amet pulvinar ligula viverra facilisis. Morbi lacus lacus, finibus quis hendrerit at, gravida quis arcu. Solution Proin imperdiet ipsum nisi, et ullamcorper tellus gravida quis. Proin at ipsum et tortor bibendum gravida.","title":"Common issues"},{"location":"issues/#placeholder","text":"Integer faucibus justo neque. Vivamus vitae posuere tellus. Pellentesque aliquet semper nisi, sit amet pulvinar ligula viverra facilisis. Morbi lacus lacus, finibus quis hendrerit at, gravida quis arcu. Solution Proin imperdiet ipsum nisi, et ullamcorper tellus gravida quis. Proin at ipsum et tortor bibendum gravida.","title":"Placeholder"},{"location":"exports/","text":"","title":"Index"},{"location":"exports/execute/","text":"Generic function that can be utilised for any query, synonymous with fetch. When selecting data it will return all matching rows and columns, otherwise it will return field data such as insertid, affectedRows, etc. Example Lua Async exports . oxmysql : execute ( 'SELECT * FROM users WHERE identifier = ?' , { playerIdentifier }, function ( result ) if result then for _ , v in pairs ( result ) do print ( v . identifier , v . firstname , v . lastname ) end end end ) Sync local result = exports . oxmysql : executeSync ( 'SELECT * FROM users WHERE identifier = ?' , { playerIdentifier }) if result then for _ , v in pairs ( result ) do print ( v . identifier , v . firstname , v . lastname ) end end JavaScript Async exports . oxmysql . execute ( 'SELECT * FROM users WHERE identifier = ?' , [ playerIdentifier ], function ( result ) { if ( result ) { result . forEach (( v ) => { console . log ( v . identifier , v . firstname , v . lastname ) }) } }) Sync const result = exports . oxmysql . executeSync ( 'SELECT * FROM users WHERE identifier = ?' , [ playerIdentifier ]) { if ( result ) { result . forEach (( v ) => { console . log ( v . identifier , v . firstname , v . lastname ) }) }","title":"Execute"},{"location":"exports/insert/","text":"Inserts a new entry into the database and returns the insert id for the row, if valid. Example Lua Async exports . oxmysql : insert ( 'INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ' , { playerIdentifier , firstName , lastName }, function ( id ) if id then print ( id ) end end ) Sync local id = exports . oxmysql : insertSync ( 'INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ' , { playerIdentifier , firstName , lastName }) if id then print ( id ) end JavaScript Async exports . oxmysql . insert ( 'INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ' , [ playerIdentifier , firstName , lastName ], function ( id ) { if ( id ) console . log ( id ) }) Sync const id = exports . oxmysql . insertSync ( 'INSERT INTO users (identifier, firstname, lastname) VALUES (?, ?, ?) ' , [ playerIdentifier , firstName , lastName ]) { if ( id ) console . log ( id )","title":"Insert"},{"location":"exports/prepare/","text":"TODO","title":"Prepare"},{"location":"exports/scalar/","text":"Returns the first column for a single row. Example Lua Async exports . oxmysql : scalar ( 'SELECT firstname FROM users WHERE identifier = ?' , { playerIdentifier }, function ( result ) if result then print ( result . firstname ) end end ) Sync local result = exports . oxmysql : scalarSync ( 'SELECT firstname FROM users WHERE identifier = ?' , { playerIdentifier }) if result then print ( result . firstname ) end JavaScript Async exports . oxmysql . scalar ( 'SELECT firstname FROM users WHERE identifier = ?' , [ playerIdentifier ], function ( result ) { if ( result ) console . log ( result . firstname ) }) Sync const result = exports . oxmysql . scalarSync ( 'SELECT firstname FROM users WHERE identifier = ?' , [ playerIdentifier ]) { if ( result ) console . log ( result . firstname )","title":"Scalar"},{"location":"exports/single/","text":"Returns the columns for a single row. Example Lua Async exports . oxmysql : single ( 'SELECT * FROM users WHERE identifier = ?' , { playerIdentifier }, function ( result ) if result then print ( result . identifier , result . firstname , result . lastname ) end end ) Sync local result = exports . oxmysql : singleSync ( 'SELECT * FROM users WHERE identifier = ?' , { playerIdentifier }) if result then print ( result . identifier , result . firstname , result . lastname ) end JavaScript Async exports . oxmysql . single ( 'SELECT * FROM users WHERE identifier = ?' , [ playerIdentifier ], function ( result ) { if ( result ) console . log ( result . identifier , result . firstname , result . lastname ) }) Sync const result = exports . oxmysql . singleSync ( 'SELECT * FROM users WHERE identifier = ?' , [ playerIdentifier ]) { if ( result ) console . log ( result . identifier , result . firstname , result . lastname )","title":"Single"},{"location":"exports/transaction/","text":"Transactions \u00b6 A transaction executes multiple queries and commits them only if all succeed. If one fails, none of the queries are committed. The return value is a boolean , which is the result of the transaction. Specific Format \u00b6 When using the Specific format you must pass one parameter to the oxmysql export. In this case, the queries parameter contains your queries and the SQL variables unique to each query. This is useful for transactions where the queries do not share many SQL variables. Usage \u00b6 Lua local queries = { { query = 'INSERT INTO `test` (id) VALUES (:someid)' , values = { [ 'someid' ] = 1 } }, { query = 'INSERT INTO `test` (id) VALUES (:someid)' , values = { [ 'someid' ] = 2 } } } -- NOTE, the 'values' tables can be named 'parameters' here for MySQL-Async compatibility. -- Async exports . oxmysql : transaction ( queries , function ( result ) print ( result ) end ) -- Sync local result = exports . oxmysql : transactionSync ( queries ) print ( result ) JavaScript const queries = [ { query = 'INSERT INTO `test` (id) VALUES (:someid)' , values = { someid = 1 } }, { query = 'INSERT INTO `test` (id) VALUES (:someid)' , values = { someid = 2 } } ] // NOTE, the 'values' objects can be named 'parameters' here for MySQL-Async compatibility. // Async exports . oxmysql . transaction ( queries , ( result ) => { console . log ( result ) }) // Sync const result = await exports . oxmysql . transactionSync ( queries ) console . log ( result ) Shared Format \u00b6 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 local queries = { 'INSERT INTO `test` (id, name) VALUES (:someid, :somename)' , 'SET `name` = :newname IN `test` WHERE `id` = :someid' } local parameters = { [ 'someid' ] = 2 , [ 'somename' ] = 'John Doe' , [ 'newname' ] = 'John Notdoe' } -- Async exports . oxmysql : transaction ( queries , parameters , function ( result ) print ( result ) end ) -- Sync local result = exports . oxmysql : transactionSync ( queries , parameters ) print ( result ) JavaScript const queries = [ 'INSERT INTO `test` (id, name) VALUES (:someid, :somename)' , 'SET `name` = :newname IN `test` WHERE `id` = :someid' ] const parameters = { someid = 2 , somename = 'John Doe' , newname = 'John Notdoe' } // Async exports . oxmysql . transaction ( queries , parameters , ( result ) => { console . log ( result ) }) // Sync const result = await exports . oxmysql . transactionSync ( queries , parameters ) console . log ( result ) Transaction Isolation Level \u00b6 This can be set through the convar mysql_transaction_isolation_level which should be an integer ranging from 1-4 . The default convar value set by oxmysql is 2 . Convar Value Result 1 Repeatable Read 2 Read Committed 3 Read Uncommitted 4 Serializable","title":"Transactions"},{"location":"exports/transaction/#transactions","text":"A transaction executes multiple queries and commits them only if all succeed. If one fails, none of the queries are committed. The return value is a boolean , which is the result of the transaction.","title":"Transactions"},{"location":"exports/transaction/#specific-format","text":"When using the Specific format you must pass one parameter to the oxmysql export. In this case, the queries parameter contains your queries and the SQL variables unique to each query. This is useful for transactions where the queries do not share many SQL variables.","title":"Specific Format"},{"location":"exports/transaction/#usage","text":"Lua local queries = { { query = 'INSERT INTO `test` (id) VALUES (:someid)' , values = { [ 'someid' ] = 1 } }, { query = 'INSERT INTO `test` (id) VALUES (:someid)' , values = { [ 'someid' ] = 2 } } } -- NOTE, the 'values' tables can be named 'parameters' here for MySQL-Async compatibility. -- Async exports . oxmysql : transaction ( queries , function ( result ) print ( result ) end ) -- Sync local result = exports . oxmysql : transactionSync ( queries ) print ( result ) JavaScript const queries = [ { query = 'INSERT INTO `test` (id) VALUES (:someid)' , values = { someid = 1 } }, { query = 'INSERT INTO `test` (id) VALUES (:someid)' , values = { someid = 2 } } ] // NOTE, the 'values' objects can be named 'parameters' here for MySQL-Async compatibility. // Async exports . oxmysql . transaction ( queries , ( result ) => { console . log ( result ) }) // Sync const result = await exports . oxmysql . transactionSync ( queries ) console . log ( result )","title":"Usage"},{"location":"exports/transaction/#shared-format","text":"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 local queries = { 'INSERT INTO `test` (id, name) VALUES (:someid, :somename)' , 'SET `name` = :newname IN `test` WHERE `id` = :someid' } local parameters = { [ 'someid' ] = 2 , [ 'somename' ] = 'John Doe' , [ 'newname' ] = 'John Notdoe' } -- Async exports . oxmysql : transaction ( queries , parameters , function ( result ) print ( result ) end ) -- Sync local result = exports . oxmysql : transactionSync ( queries , parameters ) print ( result ) JavaScript const queries = [ 'INSERT INTO `test` (id, name) VALUES (:someid, :somename)' , 'SET `name` = :newname IN `test` WHERE `id` = :someid' ] const parameters = { someid = 2 , somename = 'John Doe' , newname = 'John Notdoe' } // Async exports . oxmysql . transaction ( queries , parameters , ( result ) => { console . log ( result ) }) // Sync const result = await exports . oxmysql . transactionSync ( queries , parameters ) console . log ( result )","title":"Shared Format"},{"location":"exports/transaction/#transaction-isolation-level","text":"This can be set through the convar mysql_transaction_isolation_level which should be an integer ranging from 1-4 . The default convar value set by oxmysql is 2 . Convar Value Result 1 Repeatable Read 2 Read Committed 3 Read Uncommitted 4 Serializable","title":"Transaction Isolation Level"},{"location":"exports/update/","text":"Updates an entry in the database and returns the number of affected rows. Example Lua Async exports . oxmysql : insert ( 'UPDATE users SET firstname = ? WHERE identifier = ? ' , { newName , playerIdentifier }, function ( affectedRows ) if affectedRows then print ( affectedRows ) end end ) Sync local id = exports . oxmysql : insertSync ( 'UPDATE users SET firstname = ? WHERE identifier = ? ' , { newName , playerIdentifier }) if affectedRows then print ( affectedRows ) end JavaScript Async exports . oxmysql . insert ( 'UPDATE users SET firstname = ? WHERE identifier = ? ' , [ newName , playerIdentifier ], function ( affectedRows ) { if ( affectedRows ) console . log ( affectedRows ) }) Sync const id = exports . oxmysql . insertSync ( 'UPDATE users SET firstname = ? WHERE identifier = ? ' , [ newName , playerIdentifier ]) { if ( affectedRows ) console . log ( affectedRows )","title":"Update"}]} \ No newline at end of file diff --git a/sitemap.xml.gz b/sitemap.xml.gz index 8659ba948b4ef3c5c280a262988e78ec85002284..d80bdde85650491425f23565d9f6aafc90851644 100644 GIT binary patch delta 14 VcmX@Zc!rTpzMF%ixNjocF#sX$1i1hJ delta 14 VcmX@Zc!rTpzMF$1sdpmVF#sWy1g8K1