09.09.2017, 15:02
Since SQL is full of eh.. whatever
This is what I want to do in 1 single query:
insert data to table if row doesn't exist and then select the data
or if row exists, select data
How exactly would I write this in one single threaded query? This is how I would've done it: in plain PAWN:
If I'm not completely mistaken, how can I shorten this up to one single query?
This is what I want to do in 1 single query:
insert data to table if row doesn't exist and then select the data
or if row exists, select data
How exactly would I write this in one single threaded query? This is how I would've done it: in plain PAWN:
PHP код:
mysql_tquery(MYSQL_DEFAULT_HANDLE, "SELECT * FROM player_stats WHERE id = 5 LIMIT 1", "OnQueryLoad_PlayerStats", "i," playerid);
forward public OnQueryLoad_PlayerStats(playerid);
public OnQueryLoad_PlayerStats(playerid) {
if(cache_num_rows() == 0) {
mysql_tquery(MYSQL_DEFAULT_HANDLE, "INSERT INTO player_stats SET (id, name, etc) VALUES (1, 'Meller', 'etc etc');", "i," playerid);
}
}
((ignored typos, wrote it in the browser :( ))