-
Notifications
You must be signed in to change notification settings - Fork 0
Migrating from SA MP MySQL
Xyranaut edited this page Jun 1, 2026
·
2 revisions
omp-MySQL uses a modern, industry-standard API — it does not reuse SA-MP-MySQL's native names. The concepts are the same; the names and a couple of conventions changed for the better. The full one-to-one mapping of every function is in the Native reference; this page is the orientation.
-
Prepared-statement parameters are 1-based (JDBC-style): the first
?is index 1, not 0. -
Result values use the
mysql_rs_*family (a ResultSet), replacingcache_*.
| You used to call (SA-MP-MySQL) | Now call (omp-MySQL) |
|---|---|
mysql_connect |
mysql_connect(host, user, pass, db, cfg) — TLS mandatory
|
mysql_connect_file |
mysql_connect_config("mysql.ini") |
mysql_close |
mysql_close |
mysql_tquery |
mysql_execute(h, query, cb, fmt, ...) |
mysql_pquery |
mysql_execute_for(h, query, cb, fmt, ...) (player-bound) |
mysql_query |
mysql_execute_sync(h, query) |
mysql_format |
mysql_format (now %e escape, %q quote-ident) |
mysql_escape_string |
mysql_escape (prefer prepared statements) |
mysql_errno / mysql_error
|
mysql_errno / mysql_error
|
mysql_stat |
mysql_server_status |
mysql_get_ssl_cipher |
mysql_get_tls_cipher |
cache_get_value_name_int etc. |
mysql_rs_get_int_by / mysql_rs_get_string_by / … |
cache_num_rows |
mysql_rs_row_count |
cache_insert_id |
mysql_rs_insert_id |
| (no equivalent) |
mysql_prepare + mysql_stmt_set_* — prepared statements
|
| (no equivalent) |
mysql_hash / mysql_verify — Argon2id
|
orm_* |
mysql_model_* — active-record models |
Before (SA-MP-MySQL):
new query[128];
mysql_format(g_DB, query, sizeof query,
"SELECT * FROM users WHERE name = '%e'", name);
mysql_tquery(g_DB, query, "OnLogin", "d", playerid);
public OnLogin(playerid) {
if (cache_num_rows()) {
new money = cache_get_value_name_int(0, "money");
}
}After (omp-MySQL) — same idea, or better, a prepared statement:
new PreparedStatement:st = mysql_prepare(g_DB,
"SELECT * FROM users WHERE name = ?");
mysql_stmt_set_string(st, 1, name);
mysql_stmt_execute(st, "OnLogin", "d", playerid);
public OnLogin(playerid) {
new rows; mysql_rs_row_count(rows);
if (rows) {
new money; mysql_rs_get_int_by(0, "money", money);
}
return 1;
}-
Add TLS — make sure your MySQL server supports it (5.7+ does by default) and
pick an
SSL_MODE(see Configuration). There's no "off". -
Move secrets to
${ENV}— stop hardcoding the password. -
Switch password hashing to
mysql_hash/mysql_verify(Argon2id) instead of whatever you were doing in Pawn. - Replace string-built queries with prepared statements where player input is involved.
See the complete function list: Native reference.
Understand
Use
- Installing MySQL
- Docker Compose
- Getting started
- Configuration
- SQL crash course
- Designing your tables
- Storing game data
- Dates & times
- First queries
- Async patterns
- Reading results
- Prepared statements
- Passwords & hashing
- Transactions
- Models (active-record)
- Tutorial: login system
- mysql-admin demo
Deeper
Reference