github overextended/oxmysql v1.4.0

latest releases: v2.12.0, v2.11.2, v2.11.1...
3 years ago

Transactions are now supported thanks to @darksaid98

Syntax:

 -- Shared Param Format
local queries = {
    'INSERT INTO `bans` (token) VALUES (:test)',
    'INSERT INTO `bans` (token) VALUES (:test)',
    'INSERT INTO `bans` (token) VALUES (:test)',
}
local params = { ['test'] = 'thisisatestvalue' }
    
exports.oxmysql:transaction(queries, params, function(result) 
    print(result) -- true/false
end)

 -- Specific Format
local queries = {
    { query = 'INSERT INTO `test` (id, text) VALUES (:nene, :meme)', values = { ['nene'] = 'thisisatest', ['meme'] = 'this is a text' } },
    { query = 'INSERT INTO `test` (id, text) VALUES (:nene, :meme)', values = { ['nene'] = 'thisisates2', ['meme'] = 'this is a text' } },
    { query = 'INSERT INTO `test` (id) VALUES (:nene)', parameters = { ['nene'] = 'thisisatest4' } },
}

exports.oxmysql:transaction(queries, function(result) 
    print(result) -- true/false
end)

Allows setting isolation level for transactions through convar mysql_transaction_isolation_level.

The default value is 2, it accepts integers 1-4.

  switch (GetConvarInt('mysql_transaction_isolation_level', 2)) {
    case 1:
      return 'SET TRANSACTION ISOLATION LEVEL REPEATABLE READ';
    case 2:
      return 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED';
    case 3:
      return 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED';
    case 4:
      return 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE';
    default:
      return 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED';
  };

Features

Code Refactoring

  • Transaction tweaks and version bump 1.4.0 (dunak-debug)

Don't miss a new oxmysql release

NewReleases is sending notifications on new releases.