Core/DBLayer: Convert PAppend() queries to prepared statements No.1

This commit is contained in:
leak committed 2012-03-25 16:25:06 +02:00
1 parent 56fac5e1af
commit c6cbe4c77c
22 files changed
+288 -91

No files matched your search

@@ -686,29 +686,34 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
data.spawnMask = spawnMask;
data.artKit = GetGoArtKit();
// update in DB
std::ostringstream ss;
ss << "INSERT INTO gameobject VALUES ("
<< m_DBTableGuid << ','
<< GetEntry() << ','
<< mapid << ','
<< uint32(spawnMask) << ',' // cast to prevent save as symbol
<< uint16(GetPhaseMask()) << ',' // prevent out of range error
<< GetPositionX() << ','
<< GetPositionY() << ','
<< GetPositionZ() << ','
<< GetOrientation() << ','
<< GetFloatValue(GAMEOBJECT_PARENTROTATION) << ','
<< GetFloatValue(GAMEOBJECT_PARENTROTATION+1) << ','
<< GetFloatValue(GAMEOBJECT_PARENTROTATION+2) << ','
<< GetFloatValue(GAMEOBJECT_PARENTROTATION+3) << ','
<< m_respawnDelayTime << ','
<< uint32(GetGoAnimProgress()) << ','
<< uint32(GetGoState()) << ')';
// Update in DB
SQLTransaction trans = WorldDatabase.BeginTransaction();
trans->PAppend("DELETE FROM gameobject WHERE guid = '%u'", m_DBTableGuid);
trans->Append(ss.str().c_str());
uint8 index = 0;
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAMEOBJECT);
stmt->setUInt32(0, m_DBTableGuid);
trans->Append(stmt);
stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_GAMEOBJECT);
stmt->setUInt32(index++, m_DBTableGuid);
stmt->setUInt32(index++, GetEntry());
stmt->setUInt16(index++, uint16(mapid));
stmt->setUInt8(index++, spawnMask);
stmt->setUInt16(index++, uint16(GetPhaseMask()));
stmt->setFloat(index++, GetPositionX());
stmt->setFloat(index++, GetPositionY());
stmt->setFloat(index++, GetPositionZ());
stmt->setFloat(index++, GetOrientation());
stmt->setFloat(index++, GetFloatValue(GAMEOBJECT_PARENTROTATION));
stmt->setFloat(index++, GetFloatValue(GAMEOBJECT_PARENTROTATION+1));
stmt->setFloat(index++, GetFloatValue(GAMEOBJECT_PARENTROTATION+2));
stmt->setFloat(index++, GetFloatValue(GAMEOBJECT_PARENTROTATION+3));
stmt->setInt32(index++, int32(m_respawnDelayTime));
stmt->setUInt8(index++, GetGoAnimProgress());
stmt->setUInt8(index++, uint8(GetGoState()));
trans->Append(stmt);
WorldDatabase.CommitTransaction(trans);
}