diff options
| author | Machiavelli <none@none> | 2010-09-11 21:22:15 +0200 |
|---|---|---|
| committer | Machiavelli <none@none> | 2010-09-11 21:22:15 +0200 |
| commit | 1de7e5bed179a2c1bcaf7cdb68fb377c39afd51a (patch) | |
| tree | 3b70e65e5b3150e72bc274d868c0f92376296fe4 /src/server/authserver/Realms | |
| parent | a41e99223e1dfe707afd0fa8004bcb6f267f0f04 (diff) | |
Core/DBLayer:
* Example implementation of prepared statements with resultset in RealmList and AuthSocket code (selectively)
* Also correct a few bobo´s from previous commit.
--HG--
branch : trunk
Diffstat (limited to 'src/server/authserver/Realms')
| -rw-r--r-- | src/server/authserver/Realms/RealmList.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/server/authserver/Realms/RealmList.cpp b/src/server/authserver/Realms/RealmList.cpp index 63cadf7cb22..42b63c9e322 100644 --- a/src/server/authserver/Realms/RealmList.cpp +++ b/src/server/authserver/Realms/RealmList.cpp @@ -78,20 +78,30 @@ void RealmList::UpdateRealms(bool init) { sLog.outDetail("Updating Realm List..."); - QueryResult_AutoPtr result = LoginDatabase.Query("SELECT id, name, address, port, icon, color, timezone, allowedSecurityLevel, population, gamebuild FROM realmlist WHERE color <> 3 ORDER BY name"); + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_REALMLIST); + PreparedQueryResult result = LoginDatabase.Query(stmt); ///- Circle through results and add them to the realm map if (result) { do { - Field *fields = result->Fetch(); + uint32 realmId = result->GetUInt32(0); + const std::string& name = result->GetString(1); + const std::string& address = result->GetString(2); + uint32 port = result->GetUInt32(3); + uint8 icon = result->GetUInt8(4); + uint8 color = result->GetUInt8(5); + uint8 timezone = result->GetUInt8(6); + uint8 allowedSecurityLevel = result->GetUInt8(7); + float pop = result->GetFloat(8); + uint32 build = result->GetUInt32(9); + + UpdateRealm(realmId, name, address, port, icon, color, timezone, (allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), pop, build); - uint8 allowedSecurityLevel = fields[7].GetUInt8(); - - UpdateRealm(fields[0].GetUInt32(), fields[1].GetCppString(),fields[2].GetCppString(),fields[3].GetUInt32(),fields[4].GetUInt8(), fields[5].GetUInt8(), fields[6].GetUInt8(), (allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), fields[8].GetFloat(), fields[9].GetUInt32()); if (init) - sLog.outString("Added realm \"%s\".", fields[1].GetString()); - } while(result->NextRow()); + sLog.outString("Added realm \"%s\".", result->GetString(1).c_str()); + } + while (result->NextRow()); } } |
