Core/DBLayer: Convert PExecute() queries to prepared statements No. 2
This commit is contained in:
1 parent
ea7b0b064d
commit
e646dbb3cd
19 files changed
+447
-153
No files matched your search
@@ -138,7 +138,14 @@ void InstanceSaveManager::RemoveInstanceSave(uint32 InstanceId)
|
||||
{
|
||||
// save the resettime for normal instances only when they get unloaded
|
||||
if (time_t resettime = itr->second->GetResetTimeForDB())
|
||||
CharacterDatabase.PExecute("UPDATE instance SET resettime = '"UI64FMTD"' WHERE id = '%u'", (uint64)resettime, InstanceId);
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPDATE_INSTANCE_RESETTIME);
|
||||
|
||||
stmt->setUInt32(0, uint32(resettime));
|
||||
stmt->setUInt32(1, InstanceId);
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
delete itr->second;
|
||||
m_instanceSaveById.erase(itr);
|
||||
@@ -573,13 +580,19 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b
|
||||
if (period < DAY)
|
||||
period = DAY;
|
||||
|
||||
uint64 next_reset = ((resetTime + MINUTE) / DAY * DAY) + period + diff;
|
||||
uint32 next_reset = ((resetTime + MINUTE) / DAY * DAY) + period + diff;
|
||||
|
||||
SetResetTimeFor(mapid, difficulty, next_reset);
|
||||
ScheduleReset(true, time_t(next_reset-3600), InstResetEvent(1, mapid, difficulty, 0));
|
||||
|
||||
// update it in the DB
|
||||
CharacterDatabase.PExecute("UPDATE instance_reset SET resettime = '%u' WHERE mapid = '%d' AND difficulty = '%d'", uint32(next_reset), mapid, difficulty);
|
||||
// Update it in the DB
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPDATE_GLOBAL_INSTANCE_RESETTIME);
|
||||
|
||||
stmt->setUInt32(0, next_reset);
|
||||
stmt->setUInt16(1, uint16(mapid));
|
||||
stmt->setUInt8(2, uint8(difficulty));
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
// note: this isn't fast but it's meant to be executed very rarely
|
||||
|
||||
Reference in new issue
Block a user