Skip to content

MySQL_ParallelQuery

imshooter edited this page Oct 24, 2026 · 1 revision

Send a query that any connection of the pool may run, out of order with the rest.

Without a pool, it runs in order as MySQL_Query does.

native bool:MySQL_ParallelQuery(
    MySQL:handle,
    const callback[],
    context,
    const query[],
    MYSQL_TAGS:...
);

Parameters

Parameter Description
MySQL:handle Handle to send it through.
const callback[] Public to call.
context Value the public receives.
const query[] The query, formatted with the values after it.
MYSQL_TAGS:... Values for the specifiers of the query, in order.

Returns

  • true when it was sent.
  • false when the handle does not exist, the format is not valid, or a limit of the connection refused it, and the public is not called.

Remarks

The pool is set with the pool option of the handle. Without a pool the query runs in order with the rest. A parallel query may finish before a query sent earlier, so it suits reads that do not depend on writes still waiting, such as a list for a menu or a ranking.

Example

new MySQL:gDatabase;

forward OnRankingRead(playerid);

stock ShowRanking(playerid) {
    MySQL_ParallelQuery(gDatabase, "OnRankingRead", playerid, "SELECT name, score FROM players ORDER BY score DESC LIMIT 10");
}

public OnRankingRead(playerid) {
    new
        name[MAX_PLAYER_NAME + 1]
    ;

    for (new row, rows = MySQL_GetRowCount(); row != rows; ++row) {
        MySQL_GetString(row, "name", name);
        SendClientMessage(playerid, -1, "%i. %s, %i", row + 1, name, MySQL_GetInt(row, "score"));
    }

    return 1;
}

Related

Clone this wiki locally