Repository navigation
MySQL_Run
imshooter edited this page Nov 3, 2026
·
3 revisions
Run a query and wait for it, after the queries sent before it.
Its result is the one read until the next MySQL_Run, or until the public that ran it returns. The server stops while it waits, so it suits the tables made at start up.
native bool:MySQL_Run(MySQL:handle, const query[], MYSQL_TAGS:...);| Parameter | Description |
|---|---|
MySQL:handle |
Handle to run it through. |
const query[] |
The query, formatted with the values after it. |
MYSQL_TAGS:... |
Values for the specifiers of the query, in order. |
-
truewhen it succeeded. -
falsewhen it failed, the handle does not exist, the format is not valid, or a limit of the connection refused it.
The game thread waits until the query ends, and the queries sent before it on the handle run first, so a slow query or a long queue stalls the server for that long. It suits the start of the server, such as creating tables, and quick reads that cannot wait.
Its result is the one the MySQL_Get natives read until the next query. Inside the public of another query, it replaces the result of that public until the public returns.
new MySQL:gDatabase;
public OnGameModeInit() {
gDatabase = MySQL_ConnectFile("mysql.ini");
MySQL_Run(gDatabase, "\
CREATE TABLE IF NOT EXISTS players ( \
id INT AUTO_INCREMENT PRIMARY KEY, \
name VARCHAR(24) NOT NULL UNIQUE, \
score INT NOT NULL DEFAULT 0 \
)\
");
new
total
;
if (MySQL_Run(gDatabase, "SELECT COUNT(*) AS total FROM players") && MySQL_GetValueInt(0, "total", total)) {
printf("%i players are registered.", total);
}
return 1;
}-
MySQL_ThreadedQuery: Send a query, and call a public with
contextwhen it is done. -
MySQL_RunQuery: Run a query built in pieces and wait for it, as
MySQL_Rundoes, and forget it. -
MySQL_RunStatement: Run a statement once and wait for it, as
MySQL_Rundoes.
MySQL 0.3.0 · Repository · Releases · MIT License
Guides
- Installation
- Configuration
- Queries
- Results
- JSON cells
- Prepared statements
- Passwords
- Errors
- TLS
- Coming from R41
- Performance
Reference
Functions