Repository navigation
MySQL_CreateQuery
imshooter edited this page Oct 24, 2026
·
1 revision
Start a query to build a piece at a time.
native Query:MySQL_CreateQuery(MySQL:handle, const text[] = "", MYSQL_TAGS:...);| Parameter | Description | Default |
|---|---|---|
MySQL:handle |
Handle to send it through. | |
const text[] |
First piece, formatted with the values after it. | "" |
MYSQL_TAGS:... |
Values for the specifiers of the query, in order. |
- The query.
-
INVALID_QUERY_IDwhen the handle does not exist or the format is not valid.
A query built in pieces lives in the component, so it has no length limit and no array. It belongs to the script, and is forgotten when sent, destroyed, or when the script unloads. Its text can go into another query with %Q, so a statement made of parts that grow together keeps each part in a query of its own. See Queries.
Inserts every player in one query.
new MySQL:gDatabase;
stock SaveEveryone() {
new
name[MAX_PLAYER_NAME + 1],
rows,
Query:query = MySQL_CreateQuery(gDatabase, "INSERT INTO sessions (name, score) VALUES ")
;
for (new i; i != MAX_PLAYERS; ++i) {
if (!IsPlayerConnected(i)) {
continue;
}
GetPlayerName(i, name, sizeof (name));
MySQL_AppendQuery(query, "(%q, %i), ", name, GetPlayerScore(i));
++rows;
}
if (rows == 0) {
MySQL_DestroyQuery(query);
return;
}
MySQL_TrimQuery(query, 2);
MySQL_SendQuery(query);
}- MySQL_AppendQuery: Add a piece to a query.
- MySQL_SendQuery: Send a query built in pieces, and forget it, also when it is refused.
- MySQL_DestroyQuery: Forget a query being built without sending it.
MySQL 0.2.0 · Repository · Releases · MIT License
Guides
- Installation
- Configuration
- Queries
- Results
- JSON cells
- Prepared statements
- Passwords
- Errors
- TLS
- Coming from R41
- Performance
Reference
Functions