Hello everyone,
I am trying to understand why I get garbage result from the following code:
PrepareStatement(CHAR_SEL_BY_PERSONAL_RATING,
"SELECT art.arenaTeamId, c.name, am.personalRating "
"FROM arena_team art "
"INNER JOIN arena_team_member am ON art.arenateamid = am.arenateamid "
"INNER JOIN characters c ON am.guid = c.guid "
"WHERE art.type = ? "
"AND am.personalRating > 0 "
"ORDER BY am.personalRating DESC "
“LIMIT ?”, CONNECTION_SYNCH);
So this query will return top players by personal rating in 2v2, 3v3 or 5v5 arena, and the code that calls it:
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_BY_PERSONAL_RATING);
stmt->setUInt8(0, arenaTeamType);
stmt->setUInt16(1, TOP_PLAYER_LIMIT);
PersonalRatingInfoContainer results;
if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
{
do
{
Field* fields = result->Fetch();
uint32 arenaTeamId = fields[0].GetUInt32();
std::string charName = fields[1].GetString();
uint32 personalRating = fields[2].GetUInt32(); // RETURNS GARBAGE?
results.push_back(PersonalRatingInfo(arenaTeamId, charName, personalRating));
} while (result->NextRow());
}
return results;
I don’t understand why I get garbage result for “personalRating”, for arenaTeamId and charName it seems fine, also running the query directly in DB will return the expected results.
Thank you!