Repository navigation
MySQL_Query
imshooter edited this page Oct 24, 2026
·
1 revision
Send a query, and call a public with context when it is done.
The queries of a handle run in the order they were sent. The public is called also when the query failed, and MySQL_GetErrno gives its error.
native bool:MySQL_Query(MySQL:handle, const callback[], context, const query[], MYSQL_TAGS:...);| 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. |
-
truewhen it was sent. -
falsewhen the handle does not exist, the format is not valid, or a limit of the connection refused it, and the public is not called.
The public is called on a later server tick, with the result of the query as the one the MySQL_Get natives read. It is called also when the query failed, after OnMySQLError, so it checks MySQL_GetErrno when that matters. A public that does not exist is logged when the query ends.
Queries of one handle run one after another on one connection, so a query sees what the queries sent before it wrote.
new MySQL:gDatabase;
forward OnBansRead(playerid);
public OnPlayerConnect(playerid) {
new
ip[16]
;
GetPlayerIp(playerid, ip, sizeof (ip));
MySQL_Query(gDatabase, "OnBansRead", playerid, "SELECT reason FROM bans WHERE ip = %q LIMIT 1", ip);
return 1;
}
public OnBansRead(playerid) {
new
reason[64]
;
if (MySQL_GetErrno() != 0 || MySQL_GetRowCount() == 0) {
return 1;
}
MySQL_GetString(0, "reason", reason);
SendClientMessage(playerid, -1, "You are banned: %s", reason);
Kick(playerid);
return 1;
}- MySQL_Send: Send a query that needs no answer.
- MySQL_ParallelQuery: Send a query that any connection of the pool may run, out of order with the rest.
- MySQL_Run: Run a query and wait for it, after the queries sent before it.
- MySQL_GetErrno: The error of the query read.
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