21.08.2014, 15:14
Well, then it's quite straightforward:
I can't recommend mysql_format as %e and few other arguments are broken before R9. Also bear in mind that I never wrote any unthreaded queries (and if you can, please upgrade to them before your server lags to death).
Of course change "fieldname" and "tablename", and change your where clause (and if your string gets longer watch out for size of query variable - it's only 64 at the moment)
Код:
SELECT fieldname FROM yourtable WHERE somecondition = somevalue LIMIT
pawn Код:
new
id = 666,
query[64];
format(query, sizeof query, "SELECT fieldname FROM yourtable WHERE id = %d LIMIT 0, 1", id);
mysql_query(query);
mysql_store_result();
if(mysql_errno() != 0 || mysql_num_rows() == 0) {
printf("[Err]: Something wrong when executing query with parameter %d", id);
} else {
new
fieldvalue = mysql_fetch_int();
printf("Fetched value %d for %d!", fieldvalue, id);
}
mysql_free_result();