Skip to content

MySQL_ClearQuery

imshooter edited this page Oct 24, 2026 · 1 revision

Empty a query being built, to build another in it.

native bool:MySQL_ClearQuery(Query:query);

Parameters

Parameter Description
Query:query Query to empty.

Returns

  • true when it was emptied.
  • false when it does not exist.

Remarks

The query keeps its handle, so one query can be filled again and again, such as the JSON of each row of a batch, without making a new one each time.

Example

Writes the attributes of each item as JSON and adds them to a batch.

new
    Statement:gSaveItem,
    gItemName[100][32],
    gItemAmount[100]
;

stock SaveItems(MySQL:handle) {
    new const
        Batch:batch = MySQL_CreateBatch(gSaveItem),
        Query:json = MySQL_CreateQuery(handle)
    ;

    for (new i; i != sizeof (gItemAmount); ++i) {
        MySQL_ClearQuery(json);
        MySQL_AppendQuery(json, "{%j: %j, %j: %i}", "name", gItemName[i], "amount", gItemAmount[i]);
        MySQL_AddRow(batch, i, json);
    }

    MySQL_DestroyQuery(json);
    MySQL_ExecuteBatch(batch);
}

Related

  • MySQL_CreateQuery: Start a query to build a piece at a time.
  • MySQL_TrimQuery: Remove characters from the end of a query, such as the comma after the last row.

Clone this wiki locally