This script is significantly faster than mysql-async based on my testing.
for example:
{
"host": "localhost",
"user": "root",
"password": "",
"database": "roleplay"
}
fxmanifest.lua
server_script '@mysql/import.lua'
Arguments
- callback: function, returns mysql query result optional
- queryString: string
- args: table
dbQuery(callback, queryString, args)
Example
With callback
dbQuery(
function(result)
print(#result) --print result table lenght
end,
"SELECT * FROM users WHERE identifier = ? LIMIT 1",
{
identifier,
}
)
Without callback
local result = dbQuery(
"SELECT * FROM users WHERE identifier = ? LIMIT 1",
{
identifier,
}
)
Query arguments not table
local result = dbQuery("SELECT * FROM users WHERE identifier = ? LIMIT 1", identifier)
Arguments:
- queryString: string
- args: table
Returns:
boolean, (note: if it runs successfully it returns a true value)
dbExec(queryString, args)
Example
dbExec("INSERT INTO users SET name = ?", {
GetPlayerName(player),
})
dbExec("INSERT INTO users SET name = ?", GetPlayerName(player) )