Skip to content

MySQL_GetRow

imshooter edited this page Oct 24, 2026 · 1 revision

Read the cells of a row into variables in one call, field after field.

Each letter of format reads the next field: i an integer, f a float, b a bool and s[32] a string with the size of its array. - skips a field.

MySQL_GetRow(row, "s[37]is[64]f", uuid, slot, name, price);
native MySQL_GetRow(row, const format[], {Float, _}:...);

Parameters

Parameter Description
row The row, from 0.
const format[] The fields to read.
{Float, _}:... Values for the specifiers of the query, in order.

Returns

  • How many fields were read.

Remarks

The format has a letter for each field, in the order of the result: i or d an integer, f a float, b a boolean, s[size] a string with the size of its array, and - or _ a field to skip. Spaces are ignored. It reads a row in one call, which is faster than one native for each field.

Example

new MySQL:gDatabase;

forward OnVehiclesRead();

stock LoadVehicles() {
    MySQL_Query(gDatabase, "OnVehiclesRead", 0, "SELECT model, x, y, z, angle, plate FROM vehicles");
}

public OnVehiclesRead() {
    new
        model,
        Float:x,
        Float:y,
        Float:z,
        Float:angle,
        plate[16]
    ;

    for (new row, rows = MySQL_GetRowCount(); row != rows; ++row) {
        MySQL_GetRow(row, "iffffs[16]", model, x, y, z, angle, plate);
        SetVehicleNumberPlate(CreateVehicle(model, x, y, z, angle, -1, -1, -1), plate);
    }

    return 1;
}

Related

Clone this wiki locally