mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-01 14:38:50 +00:00
1.9 KiB
1.9 KiB
Documentation
Introduction
oxmysql is a database wrapper for FiveM utilising node-mysql2 offering improved performance and security.
Comparison
TODO
Query cache
Every executed query is being prepared and stored into cache for faster performance using prepared statements. These statements are also being sanitized from vulnerable SQL injection and accepts two types of parameters:
...'SELECT * FROM `users` WHERE `identifier` = ? AND `group` = ?', { playerIdentifier, playerGroup } ...
...'SELECT * FROM `users` WHERE `identifier` = :id AND `group` = :group', { id = playerIdentifier, group = playerGroup }
Usage
Execute
Will execute query and returns count of affected rows.
exports.oxmysql:execute(query, {}, function(affectedRows)
end)
print('I will be printed before query result')
--
local affectedRows = exports.oxmysql:executeSync(query, {})
print('I will be printed after query result')
Insert
Async wrapper
exports.oxmysql:insert(query, {}, function(insertId)
end)
print('I will be printed before query result')
--
local insertId = exports.oxmysql:insertSync(query, {})
print('I will be printed after query result')
Fetch
exports.oxmysql:fetch(query, {}, function(result)
end)
print('I will be printed before query result')
--
local result = exports.oxmysql:executeSync(query, {})
print('I will be printed after query result')
Single
exports.oxmysql:execute(query, {}, function(rowData)
end)
print('I will be printed before query result')
--
local rowData = exports.oxmysql:executeSync(query, {})
print('I will be printed after query result')
Scalar
exports.oxmysql:execute(query, {}, function(affectedRows)
end)
print('I will be printed before query result')
--
local affectedRows = exports.oxmysql:executeSync(query, {})
print('I will be printed after query result')