Repository navigation
MySQL_Prepare
Prepare a statement, with a specifier for each value.
It is sent to the server at once and runs on the connection of the handle that runs queries in order. An error in it is logged, and reported through OnMySQLError, before it first runs.
native Statement:MySQL_Prepare(MySQL:handle, const query[]);| Parameter | Description |
|---|---|
MySQL:handle |
Handle to run it through. |
const query[] |
The statement, as INSERT INTO items (uuid, slot) VALUES (%q, %i). |
- The statement.
-
INVALID_STATEMENT_IDwhen the handle does not exist or a specifier is not valid.
Each specifier becomes a ? the server fills with a value, so a value is never escaped and never parsed as SQL. %i, %d and %x take an integer, %u an unsigned one, %f a float, %s, %e, %q and %j a string, and %Q the text of a query being built. %% is a percent sign. A ? written in the text is a placeholder of its own, which makes the statement fail. See Prepared statements.
A statement belongs to the script and runs on the connection of the handle that runs queries in order. It is prepared again when that connection is lost, or when the server asks for it after a table changed.
new
MySQL:gDatabase,
Statement:gSaveScore
;
public OnGameModeInit() {
gDatabase = MySQL_ConnectFile("mysql.ini");
gSaveScore = MySQL_Prepare(gDatabase, "UPDATE players SET score = %i WHERE id = %i");
return 1;
}
stock SaveScore(playerid, accountid) {
MySQL_Execute(gSaveScore, "", 0, GetPlayerScore(playerid), accountid);
}- MySQL_Execute: Run a statement once, after the queries sent before it.
- MySQL_CreateBatch: Start a batch of rows for a statement.
- MySQL_CloseStatement: Close a statement after what was sent before it, and forget its batches.
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