cobalt_mysql
The MariaDB layer, which also answers as oxmysql, mysql-async and ghmattimysql, so exports.oxmysql, exports.ghmattimysql, exports['mysql-async'] and the @oxmysql/lib/MySQL.lua include (MySQL.Async, MySQL.Sync, MySQL.ready) all reach it.
| Export | Side | What it does |
|---|---|---|
call | Server | Runs one operation for @oxmysql/lib/MySQL.lua and returns { value } or { nil, error }, inline when the answer arrives within mysql_inline_budget_ms. |
endTransaction | Server | Commits or rolls back a startTransaction session and returns whether it committed. |
query | Server | oxmysql's callback form, kept for scripts that call exports.oxmysql directly. |
single | Server | As query, returning the first row. |
scalar | Server | As query, returning the first column of the first row. |
insert | Server | As query, returning the insert id. |
update | Server | As query, returning the affected row count. |
prepare | Server | Runs a prepared statement once per parameter set. |
rawExecute | Server | As prepare, returning mysql2's raw results. |
transaction | Server | Runs every statement in one transaction and passes whether it committed. |
startTransaction | Server | Runs fn on one connection inside a transaction; it commits unless fn returns false or errors. |
isReady | Server | Whether the pool has connected. |
awaitConnection | Server | Waits until the pool has connected. |
store | Server | Passes query back unchanged, for mysql-async's store. |
execute | Server | As query; oxmysql's older name. |
fetch | Server | As query; oxmysql's older name. |
query_async | Server | As query, returning the result to an awaiting caller and raising on error. |
querySync | Server | As query, returning the result to an awaiting caller and raising on error. |
single_async | Server | As single, returning the result to an awaiting caller and raising on error. |
singleSync | Server | As single, returning the result to an awaiting caller and raising on error. |
scalar_async | Server | As scalar, returning the result to an awaiting caller and raising on error. |
scalarSync | Server | As scalar, returning the result to an awaiting caller and raising on error. |
insert_async | Server | As insert, returning the result to an awaiting caller and raising on error. |
insertSync | Server | As insert, returning the result to an awaiting caller and raising on error. |
update_async | Server | As update, returning the result to an awaiting caller and raising on error. |
updateSync | Server | As update, returning the result to an awaiting caller and raising on error. |
prepare_async | Server | As prepare, returning the result to an awaiting caller and raising on error. |
prepareSync | Server | As prepare, returning the result to an awaiting caller and raising on error. |
rawExecute_async | Server | As rawExecute, returning the result to an awaiting caller and raising on error. |
rawExecuteSync | Server | As rawExecute, returning the result to an awaiting caller and raising on error. |
transaction_async | Server | As transaction, returning the result to an awaiting caller and raising on error. |
transactionSync | Server | As transaction, returning the result to an awaiting caller and raising on error. |
execute_async | Server | As query_async; execute is oxmysql's older name for query. |
executeSync | Server | As querySync; execute is oxmysql's older name for query. |
fetch_async | Server | As query_async; fetch is oxmysql's older name for query. |
fetchSync | Server | As querySync; fetch is oxmysql's older name for query. |
isReady_async | Server | As isReady, returned to an awaiting caller. |
isReadySync | Server | As isReady, returned to an awaiting caller. |
awaitConnection_async | Server | As awaitConnection, returned to an awaiting caller. |
awaitConnectionSync | Server | As awaitConnection, returned to an awaiting caller. |
startTransaction_async | Server | As startTransaction, returned to an awaiting caller. |
store_async | Server | As store, returned to an awaiting caller. |
startTransactionSync | Server | As startTransaction, returned to an awaiting caller. |
storeSync | Server | As store, returned to an awaiting caller. |
execute | Server | As cobalt_mysql's query. |
executeSync | Server | As cobalt_mysql's query_async. |
scalar | Server | As cobalt_mysql's scalar. |
scalarSync | Server | As cobalt_mysql's scalar_async. |
transaction | Server | As cobalt_mysql's transaction. |
transactionSync | Server | As cobalt_mysql's transaction_async. |
store | Server | As cobalt_mysql's store. |
storeSync | Server | As cobalt_mysql's store_async. |
is_ready | Server | As cobalt_mysql's isReady: whether the database connection is up. |
mysql_execute | Server | As cobalt_mysql's update. |
mysql_insert | Server | As cobalt_mysql's insert. |
mysql_fetch_all | Server | As cobalt_mysql's query. |
mysql_fetch_scalar | Server | As cobalt_mysql's scalar. |
mysql_transaction | Server | As cobalt_mysql's transaction. |
mysql_store | Server | As cobalt_mysql's store. |
cobalt_mysql and oxmysql
call
ServerRuns one operation for @oxmysql/lib/MySQL.lua and returns { value } or { nil, error }, inline when the answer arrives within mysql_inline_budget_ms.
exports.cobalt_mysql:call(op, query, parameters, resource, isPromise, session, deferred)| Parameter | Type | Optional | Description |
|---|---|---|---|
op | integer | No | 0 query, 1 single, 2 scalar, 3 insert, 4 update, 5 prepare, 6 rawExecute, 7 transaction, 8 begin, 9 query inside a transaction |
query | string | table | nil | No | |
parameters | table | nil | No | |
resource | string | No | the calling resource, used in logs |
isPromise | boolean | No | true when the caller raises or returns the error instead of having it printed |
session | integer | No | startTransaction session id, or 0 |
deferred | boolean | Yes | skip the inline wait |
| Returns | Description |
|---|---|
table | reply |
local reply = exports.cobalt_mysql:call(
1,
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' },
GetCurrentResourceName(),
true,
1,
true
)endTransaction
ServerCommits or rolls back a startTransaction session and returns whether it committed.
exports.cobalt_mysql:endTransaction(session, commit, resource, scriptError)| Parameter | Type | Optional | Description |
|---|---|---|---|
session | integer | No | |
commit | boolean | No | |
resource | string | No | |
scriptError | string | Yes | the error that ended the transaction function |
| Returns | Description |
|---|---|
boolean | committed |
local committed = exports.cobalt_mysql:endTransaction(
1,
true,
GetCurrentResourceName(),
'scriptError'
)query
Serveroxmysql's callback form, kept for scripts that call exports.oxmysql directly.
exports.cobalt_mysql:query(query, parameters, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes | |
cb | function | Yes |
exports.cobalt_mysql:query(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' },
function(result, err) end
)single
ServerAs query, returning the first row.
exports.cobalt_mysql:single(query, parameters, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes | |
cb | function | Yes |
exports.cobalt_mysql:single(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' },
function(row, err) end
)scalar
ServerAs query, returning the first column of the first row.
exports.cobalt_mysql:scalar(query, parameters, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes | |
cb | function | Yes |
exports.cobalt_mysql:scalar(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' },
function(value, err) end
)insert
ServerAs query, returning the insert id.
exports.cobalt_mysql:insert(query, parameters, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes | |
cb | function | Yes |
exports.cobalt_mysql:insert(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' },
function(insertId, err) end
)update
ServerAs query, returning the affected row count.
exports.cobalt_mysql:update(query, parameters, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes | |
cb | function | Yes |
exports.cobalt_mysql:update(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' },
function(affectedRows, err) end
)prepare
ServerRuns a prepared statement once per parameter set.
exports.cobalt_mysql:prepare(query, parameters, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes | |
cb | function | Yes |
exports.cobalt_mysql:prepare(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' },
function(result, err) end
)rawExecute
ServerAs prepare, returning mysql2's raw results.
exports.cobalt_mysql:rawExecute(query, parameters, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes | |
cb | function | Yes |
exports.cobalt_mysql:rawExecute(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' },
function(result, err) end
)transaction
ServerRuns every statement in one transaction and passes whether it committed.
exports.cobalt_mysql:transaction(queries, parameters, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
queries | table | No | |
parameters | table | Yes | |
cb | function | Yes |
exports.cobalt_mysql:transaction(
{ { query = 'UPDATE players SET cash = cash - ? WHERE citizenid = ?', values = { 100, 'ABC12345' } } },
{ 'ABC12345' },
function(committed) end
)startTransaction
ServerRuns fn on one connection inside a transaction; it commits unless fn returns false or errors.
exports.cobalt_mysql:startTransaction(fn)| Parameter | Type | Optional | Description |
|---|---|---|---|
fn | function | No |
| Returns | Description |
|---|---|
boolean | committed |
local committed = exports.cobalt_mysql:startTransaction(function(query) return true end)isReady
ServerWhether the pool has connected.
exports.cobalt_mysql:isReady()| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_mysql:isReady()awaitConnection
ServerWaits until the pool has connected.
exports.cobalt_mysql:awaitConnection()| Returns | Description |
|---|---|
true |
local result = exports.cobalt_mysql:awaitConnection()store
ServerPasses query back unchanged, for mysql-async's store.
exports.cobalt_mysql:store(query, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
cb | function | No |
exports.cobalt_mysql:store('SELECT * FROM players WHERE citizenid = ?', function(query) end)execute
ServerAs query; oxmysql's older name.
exports.cobalt_mysql:execute(query, parameters, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes | |
cb | function | Yes |
exports.cobalt_mysql:execute(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' },
function(result, err) end
)fetch
ServerAs query; oxmysql's older name.
exports.cobalt_mysql:fetch(query, parameters, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes | |
cb | function | Yes |
exports.cobalt_mysql:fetch(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' },
function(result, err) end
)query_async
ServerAs query, returning the result to an awaiting caller and raising on error.
exports.cobalt_mysql:query_async(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
any |
local result = exports.cobalt_mysql:query_async(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)querySync
ServerAs query, returning the result to an awaiting caller and raising on error.
exports.cobalt_mysql:querySync(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
any |
local result = exports.cobalt_mysql:querySync(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)single_async
ServerAs single, returning the result to an awaiting caller and raising on error.
exports.cobalt_mysql:single_async(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
table? |
local result = exports.cobalt_mysql:single_async(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)singleSync
ServerAs single, returning the result to an awaiting caller and raising on error.
exports.cobalt_mysql:singleSync(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
table? |
local result = exports.cobalt_mysql:singleSync(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)scalar_async
ServerAs scalar, returning the result to an awaiting caller and raising on error.
exports.cobalt_mysql:scalar_async(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
any |
local result = exports.cobalt_mysql:scalar_async(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)scalarSync
ServerAs scalar, returning the result to an awaiting caller and raising on error.
exports.cobalt_mysql:scalarSync(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
any |
local result = exports.cobalt_mysql:scalarSync(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)insert_async
ServerAs insert, returning the result to an awaiting caller and raising on error.
exports.cobalt_mysql:insert_async(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
integer? |
local value = exports.cobalt_mysql:insert_async(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)insertSync
ServerAs insert, returning the result to an awaiting caller and raising on error.
exports.cobalt_mysql:insertSync(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
integer? |
local value = exports.cobalt_mysql:insertSync(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)update_async
ServerAs update, returning the result to an awaiting caller and raising on error.
exports.cobalt_mysql:update_async(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
integer? |
local value = exports.cobalt_mysql:update_async(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)updateSync
ServerAs update, returning the result to an awaiting caller and raising on error.
exports.cobalt_mysql:updateSync(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
integer? |
local value = exports.cobalt_mysql:updateSync(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)prepare_async
ServerAs prepare, returning the result to an awaiting caller and raising on error.
exports.cobalt_mysql:prepare_async(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
any |
local result = exports.cobalt_mysql:prepare_async(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)prepareSync
ServerAs prepare, returning the result to an awaiting caller and raising on error.
exports.cobalt_mysql:prepareSync(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
any |
local result = exports.cobalt_mysql:prepareSync(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)rawExecute_async
ServerAs rawExecute, returning the result to an awaiting caller and raising on error.
exports.cobalt_mysql:rawExecute_async(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
any |
local result = exports.cobalt_mysql:rawExecute_async(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)rawExecuteSync
ServerAs rawExecute, returning the result to an awaiting caller and raising on error.
exports.cobalt_mysql:rawExecuteSync(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
any |
local result = exports.cobalt_mysql:rawExecuteSync(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)transaction_async
ServerAs transaction, returning the result to an awaiting caller and raising on error.
exports.cobalt_mysql:transaction_async(queries, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
queries | table | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_mysql:transaction_async(
{ { query = 'UPDATE players SET cash = cash - ? WHERE citizenid = ?', values = { 100, 'ABC12345' } } },
{ 'ABC12345' }
)transactionSync
ServerAs transaction, returning the result to an awaiting caller and raising on error.
exports.cobalt_mysql:transactionSync(queries, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
queries | table | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_mysql:transactionSync(
{ { query = 'UPDATE players SET cash = cash - ? WHERE citizenid = ?', values = { 100, 'ABC12345' } } },
{ 'ABC12345' }
)execute_async
ServerAs query_async; execute is oxmysql's older name for query.
exports.cobalt_mysql:execute_async(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
any |
local result = exports.cobalt_mysql:execute_async(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)executeSync
ServerAs querySync; execute is oxmysql's older name for query.
exports.cobalt_mysql:executeSync(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
any |
local result = exports.cobalt_mysql:executeSync(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)fetch_async
ServerAs query_async; fetch is oxmysql's older name for query.
exports.cobalt_mysql:fetch_async(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
any |
local result = exports.cobalt_mysql:fetch_async(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)fetchSync
ServerAs querySync; fetch is oxmysql's older name for query.
exports.cobalt_mysql:fetchSync(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
any |
local result = exports.cobalt_mysql:fetchSync(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)isReady_async
ServerAs isReady, returned to an awaiting caller.
exports.cobalt_mysql:isReady_async()| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_mysql:isReady_async()isReadySync
ServerAs isReady, returned to an awaiting caller.
exports.cobalt_mysql:isReadySync()| Returns | Description |
|---|---|
boolean |
local ok = exports.cobalt_mysql:isReadySync()awaitConnection_async
ServerAs awaitConnection, returned to an awaiting caller.
exports.cobalt_mysql:awaitConnection_async()| Returns | Description |
|---|---|
true |
local result = exports.cobalt_mysql:awaitConnection_async()awaitConnectionSync
ServerAs awaitConnection, returned to an awaiting caller.
exports.cobalt_mysql:awaitConnectionSync()| Returns | Description |
|---|---|
true |
local result = exports.cobalt_mysql:awaitConnectionSync()startTransaction_async
ServerAs startTransaction, returned to an awaiting caller.
exports.cobalt_mysql:startTransaction_async(fn)| Parameter | Type | Optional | Description |
|---|---|---|---|
fn | function | No |
| Returns | Description |
|---|---|
boolean | committed |
local committed = exports.cobalt_mysql:startTransaction_async(function(query) return true end)store_async
ServerAs store, returned to an awaiting caller.
exports.cobalt_mysql:store_async(query, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
cb | function | No |
exports.cobalt_mysql:store_async('SELECT * FROM players WHERE citizenid = ?', function(query) end)startTransactionSync
ServerAs startTransaction, returned to an awaiting caller.
exports.cobalt_mysql:startTransactionSync(fn)| Parameter | Type | Optional | Description |
|---|---|---|---|
fn | function | No |
| Returns | Description |
|---|---|
boolean | committed |
local committed = exports.cobalt_mysql:startTransactionSync(function(query) return true end)storeSync
ServerAs store, returned to an awaiting caller.
exports.cobalt_mysql:storeSync(query, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
cb | function | No |
exports.cobalt_mysql:storeSync('SELECT * FROM players WHERE citizenid = ?', function(query) end)ghmattimysql
execute
ServerAs cobalt_mysql's query.
exports.ghmattimysql:execute(query, parameters, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes | |
cb | function | Yes |
exports.ghmattimysql:execute(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' },
function(result, err) end
)executeSync
ServerAs cobalt_mysql's query_async.
exports.ghmattimysql:executeSync(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
any |
local result = exports.ghmattimysql:executeSync(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)scalar
ServerAs cobalt_mysql's scalar.
exports.ghmattimysql:scalar(query, parameters, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes | |
cb | function | Yes |
exports.ghmattimysql:scalar(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' },
function(value, err) end
)scalarSync
ServerAs cobalt_mysql's scalar_async.
exports.ghmattimysql:scalarSync(query, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
any |
local result = exports.ghmattimysql:scalarSync(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' }
)transaction
ServerAs cobalt_mysql's transaction.
exports.ghmattimysql:transaction(queries, parameters, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
queries | table | No | |
parameters | table | Yes | |
cb | function | Yes |
exports.ghmattimysql:transaction(
{ { query = 'UPDATE players SET cash = cash - ? WHERE citizenid = ?', values = { 100, 'ABC12345' } } },
{ 'ABC12345' },
function(committed) end
)transactionSync
ServerAs cobalt_mysql's transaction_async.
exports.ghmattimysql:transactionSync(queries, parameters)| Parameter | Type | Optional | Description |
|---|---|---|---|
queries | table | No | |
parameters | table | Yes |
| Returns | Description |
|---|---|
boolean | committed |
local committed = exports.ghmattimysql:transactionSync(
{ { query = 'UPDATE players SET cash = cash - ? WHERE citizenid = ?', values = { 100, 'ABC12345' } } },
{ 'ABC12345' }
)store
ServerAs cobalt_mysql's store.
exports.ghmattimysql:store(query, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
cb | function | No |
exports.ghmattimysql:store('SELECT * FROM players WHERE citizenid = ?', function(query) end)storeSync
ServerAs cobalt_mysql's store_async.
exports.ghmattimysql:storeSync(query, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
cb | function | No |
exports.ghmattimysql:storeSync('SELECT * FROM players WHERE citizenid = ?', function(query) end)mysql-async
is_ready
ServerAs cobalt_mysql's isReady: whether the database connection is up. mysql-async's MySQL.ready polls it.
exports['mysql-async']:is_ready()| Returns | Description |
|---|---|
boolean |
local ok = exports['mysql-async']:is_ready()mysql_execute
ServerAs cobalt_mysql's update.
exports['mysql-async']:mysql_execute(query, parameters, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes | |
cb | function | Yes |
exports['mysql-async']:mysql_execute(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' },
function(affectedRows, err) end
)mysql_insert
ServerAs cobalt_mysql's insert.
exports['mysql-async']:mysql_insert(query, parameters, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes | |
cb | function | Yes |
exports['mysql-async']:mysql_insert(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' },
function(insertId, err) end
)mysql_fetch_all
ServerAs cobalt_mysql's query.
exports['mysql-async']:mysql_fetch_all(query, parameters, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes | |
cb | function | Yes |
exports['mysql-async']:mysql_fetch_all(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' },
function(result, err) end
)mysql_fetch_scalar
ServerAs cobalt_mysql's scalar.
exports['mysql-async']:mysql_fetch_scalar(query, parameters, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
parameters | table | Yes | |
cb | function | Yes |
exports['mysql-async']:mysql_fetch_scalar(
'SELECT * FROM players WHERE citizenid = ?',
{ 'ABC12345' },
function(value, err) end
)mysql_transaction
ServerAs cobalt_mysql's transaction.
exports['mysql-async']:mysql_transaction(queries, parameters, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
queries | table | No | |
parameters | table | Yes | |
cb | function | Yes |
exports['mysql-async']:mysql_transaction(
{ { query = 'UPDATE players SET cash = cash - ? WHERE citizenid = ?', values = { 100, 'ABC12345' } } },
{ 'ABC12345' },
function(committed) end
)mysql_store
ServerAs cobalt_mysql's store.
exports['mysql-async']:mysql_store(query, cb)| Parameter | Type | Optional | Description |
|---|---|---|---|
query | string | No | |
cb | function | No |
exports['mysql-async']:mysql_store('SELECT * FROM players WHERE citizenid = ?', function(query) end)