Functions

The advantage of ice_mysql is that all the functions of other mysql handling scripts are reduced to two functions, one synchronous and one asynchronous.

MakeQuery

This function is used to execute a sql query that will receive the data through the synchronous function.

exports["ice_mysql"]:MakeQuery(db_id, query, params);

Params:

  • db_id = the identifier of the database, is the number that is in the server.cfg credentials. (OPTIONAL) Default db_id is 1.

  • query = is the query that you want to execute in the db.(*)

  • params = array of strings that will be replaced by the ? character.(OPTIONAL)

Example:

Here are 2 examples to execute a SELECT query specifying the database id, another without specifying the database id and an update query. It should be noted that the only mandatory parameter is the query.

Citizen.CreateThread(function()
    local result = exports["ice_mysql"]:MakeQuery(1, "SELECT * FROM players WHERE `group`=?", {"admin"})
    print(json.encode(result))
end)

-- or without db_id

Citizen.CreateThread(function()
    local result = exports["ice_mysql"]:MakeQuery("SELECT * FROM players WHERE `group`=?", {"admin"})
    print(json.encode(result))
end)
circle-exclamation

AsyncMakeQuery

This function is used to execute a sql query that will receive the data through a param of the function.

Params:

  • db_id = the identifier of the database, is the number that is in the server.cfg credentials. (OPTIONAL) Default db_id is 1.

  • query = is the query that you want to execute in the db.(*)

  • params = array of strings that will be replaced by the ? character.(OPTIONAL)

Example:

Here is 1 example to execute a SELECT query and an update query. It should be noted that the only mandatory parameter is the query.

Last updated