Skip to content

MySQL_Format

imshooter edited this page Oct 24, 2026 · 1 revision

Format a query into an array.

native MySQL_Format(MySQL:handle, output[], size, const format[], MYSQL_TAGS:...);

Parameters

Parameter Description
MySQL:handle Handle whose escaping is used.
output[] Array for the query.
size Size of the array.
const format[] The query, formatted with the values after it.
MYSQL_TAGS:... Values for the specifiers of the query, in order.

Returns

  • The length of the query.
  • -1 when it does not fit, and nothing is written, or the format is not valid.

Remarks

It formats as a query does, with the escaping of the handle, into an array. A query sent with MySQL_Query is formatted by the component and needs no array, so this suits a query kept to be sent later or shown.

Example

new MySQL:gDatabase;

stock ShowQuery(playerid, const name[]) {
    new
        query[128]
    ;

    if (MySQL_Format(gDatabase, query, sizeof (query), "SELECT * FROM players WHERE name = %q", name) != -1) {
        SendClientMessage(playerid, -1, query);
    }
}

Related

Clone this wiki locally