This may well be a result of the fact I am new to node and javascript in general. Me and a friend have been working on a steam App to update a CS:GO rank for a given user. All code works - e.g. checking if user is still in friend list etc. but we seem to have an issue with actually using a foreach on an SQL query which grabs all users in a table and wishes to update information about them.
CSGOCli.playerProfileRequest(CSGOCli.ToAccountID(value.steam64ID));
CSGOCli.on("playerProfile", function(profile) {
console.log('UPDATE counterStrikeGlobalOffensive SET clientRank = "'+ profile.account_profiles[0].ranking.rank_id +'",steamNick = "'+ name +'", wins = "'+ profile.account_profiles[0].ranking.wins +'", isVACBanned = "'+ profile.account_profiles[0].vac_banned +'" WHERE steam64ID = "'+ value.steam64ID +'"');
sqlll = 'UPDATE counterStrikeGlobalOffensive SET clientRank = "'+ profile.account_profiles[0].ranking.rank_id +'",steamNick = "'+ name +'", wins = "'+ profile.account_profiles[0].ranking.wins +'", isVACBanned = "'+ profile.account_profiles[0].vac_banned +'" WHERE steam64ID = "'+ value.steam64ID +'"';
con.query(sqlll, function (err, result) {
if (err) throw err;
console.log("1 record updated - csgo info.");
});
gameId = null;
});
So whats the problem? As you can see we do use a foreach rows. statement - the SQL itself is a simple SELECT * -
con.query("SELECT * FROM counterStrikeGlobalOffensive", function (err, rows) {
inside of which the above code is placed.
I come from a heavy php background so this may well be a conceptual problem - I'm thinking I need to reset the variables or something like that? Either way, its the values of
profile.account_profiles[0].ranking.rank_id
profile.account_profiles[0].ranking.wins
profile.account_profiles[0].vac_banned
that seem to get assigned once and once only.
Is there something I'm clearly doing wrong?
It is rare I ask a question, so I do apologise if something is unclear - just not sure what exact information to give on something which seems like a rather trivial thing to mess up on.
Thanks