本文整理汇总了C++中SqlStatement::addInt32方法的典型用法代码示例。如果您正苦于以下问题:C++ SqlStatement::addInt32方法的具体用法?C++ SqlStatement::addInt32怎么用?C++ SqlStatement::addInt32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlStatement
的用法示例。
在下文中一共展示了SqlStatement::addInt32方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveToDB
void Corpse::SaveToDB()
{
// prevent DB data inconsistence problems and duplicates
RealmDataDatabase.BeginTransaction();
DeleteFromDB();
static SqlStatementID saveCorpse;
SqlStatement stmt = RealmDataDatabase.CreateStatement(saveCorpse, "INSERT INTO corpse (guid,player,position_x,position_y,position_z,orientation,zone,map,data,time,corpse_type,instance) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
stmt.addUInt64(GetGUIDLow());
stmt.addUInt64(GUID_LOPART(GetOwnerGUID()));
stmt.addFloat(GetPositionX());
stmt.addFloat(GetPositionY());
stmt.addFloat(GetPositionZ());
stmt.addFloat(GetOrientation());
stmt.addUInt32(GetZoneId());
stmt.addUInt32(GetMapId());
stmt.addString(GetUInt32ValuesString());
stmt.addUInt64(m_time);
stmt.addUInt32(GetType());
stmt.addInt32(GetInstanceId());
stmt.Execute();
RealmDataDatabase.CommitTransaction();
}
示例2: SaveToDB
void Item::SaveToDB()
{
uint32 guid = GetGUIDLow();
switch(m_state)
{
case ITEM_NEW:
{
DeleteFromDB(guid);
std::ostringstream ss;
for (uint16 i = 0; i < m_valuesCount; ++i)
ss << GetUInt32Value(i) << " ";
static SqlStatementID insItem;
SqlStatement stmt = CharacterDatabase.CreateStatement(insItem, "INSERT INTO item_instance (guid, owner_guid, data, text) VALUES (?, ?, ?, ?)");
stmt.PExecute(guid, GetOwnerGuid().GetCounter(), ss.str().c_str(), m_text.c_str());
break;
}
case ITEM_CHANGED:
{
std::ostringstream ss;
for (uint16 i = 0; i < m_valuesCount; ++i)
ss << GetUInt32Value(i) << " ";
static SqlStatementID updInstance;
SqlStatement stmt = CharacterDatabase.CreateStatement(updInstance, "UPDATE item_instance SET data = ?, owner_guid = ?, text = ? WHERE guid = ?");
stmt.PExecute(ss.str().c_str(), GetOwnerGuid().GetCounter(), m_text.c_str(), guid);
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))
{
static SqlStatementID updGifts;
stmt = CharacterDatabase.CreateStatement(updGifts, "UPDATE character_gifts SET guid = ? WHERE item_guid = ?");
stmt.PExecute(GetOwnerGuid().GetCounter(), GetGUIDLow());
}
break;
}
case ITEM_REMOVED:
{
DeleteFromDB(guid);
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))
DeleteGiftsFromDB();
if (HasSavedLoot())
DeleteLootFromDB();
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE))
DeleteRefundDataFromDB();
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_BOP_TRADEABLE))
DeleteSoulboundTradeableFromDB();
delete this;
return;
}
case ITEM_UNCHANGED:
return;
}
if (m_lootState == ITEM_LOOT_CHANGED || m_lootState == ITEM_LOOT_REMOVED)
DeleteLootFromDB();
if (m_lootState == ITEM_LOOT_NEW || m_lootState == ITEM_LOOT_CHANGED)
{
if (Player* owner = GetOwner())
{
// save money as 0 itemid data
if (loot.gold)
{
static SqlStatementID saveGold;
SqlStatement stmt = CharacterDatabase.CreateStatement(saveGold, "INSERT INTO item_loot (guid, owner_guid, itemid, amount, suffix, property) VALUES (?, ?, 0, ?, 0, 0)");
stmt.PExecute(GetGUIDLow(), owner->GetGUIDLow(), loot.gold);
}
static SqlStatementID saveLoot;
SqlStatement stmt = CharacterDatabase.CreateStatement(saveLoot, "INSERT INTO item_loot (guid, owner_guid, itemid, amount, suffix, property) VALUES (?, ?, ?, ?, ?, ?)");
// save items and quest items (at load its all will added as normal, but this not important for item loot case)
for (size_t i = 0; i < loot.GetMaxSlotInLootFor(owner); ++i)
{
QuestItem* qitem = NULL;
LootItem* item = loot.LootItemInSlot(i, owner, &qitem);
if (!item)
continue;
// questitems use the blocked field for other purposes
if (!qitem && item->is_blocked)
continue;
stmt.addUInt32(GetGUIDLow());
stmt.addUInt32(owner->GetGUIDLow());
stmt.addUInt32(item->itemid);
stmt.addUInt8(item->count);
stmt.addUInt32(item->randomSuffix);
stmt.addInt32(item->randomPropertyId);
stmt.Execute();
//.........这里部分代码省略.........
示例3: SaveToDB
//.........这里部分代码省略.........
case ITEM_CHANGED:
{
static SqlStatementID updInstance ;
static SqlStatementID updGifts ;
SqlStatement stmt = CharacterDatabase.CreateStatement(updInstance, "UPDATE item_instance SET data = ?, owner_guid = ? WHERE guid = ?");
std::ostringstream ss;
for (uint16 i = 0; i < m_valuesCount; ++i)
ss << GetUInt32Value(i) << " ";
stmt.PExecute(ss.str().c_str(), GetOwnerGuid().GetCounter(), guid);
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))
{
stmt = CharacterDatabase.CreateStatement(updGifts, "UPDATE character_gifts SET guid = ? WHERE item_guid = ?");
stmt.PExecute(GetOwnerGuid().GetCounter(), GetGUIDLow());
}
} break;
case ITEM_REMOVED:
{
static SqlStatementID delItemText;
static SqlStatementID delInst ;
static SqlStatementID delGifts ;
static SqlStatementID delLoot ;
if (uint32 item_text_id = GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID))
{
SqlStatement stmt = CharacterDatabase.CreateStatement(delItemText, "DELETE FROM item_text WHERE id = ?");
stmt.PExecute(item_text_id);
}
SqlStatement stmt = CharacterDatabase.CreateStatement(delInst, "DELETE FROM item_instance WHERE guid = ?");
stmt.PExecute(guid);
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))
{
stmt = CharacterDatabase.CreateStatement(delGifts, "DELETE FROM character_gifts WHERE item_guid = ?");
stmt.PExecute(GetGUIDLow());
}
if (HasSavedLoot())
{
stmt = CharacterDatabase.CreateStatement(delLoot, "DELETE FROM item_loot WHERE guid = ?");
stmt.PExecute(GetGUIDLow());
}
delete this;
return;
}
case ITEM_UNCHANGED:
return;
}
if (m_lootState == ITEM_LOOT_CHANGED || m_lootState == ITEM_LOOT_REMOVED)
{
static SqlStatementID delLoot ;
SqlStatement stmt = CharacterDatabase.CreateStatement(delLoot, "DELETE FROM item_loot WHERE guid = ?");
stmt.PExecute(GetGUIDLow());
}
if (loot && (m_lootState == ITEM_LOOT_NEW || m_lootState == ITEM_LOOT_CHANGED))
{
if (Player* owner = GetOwner())
{
static SqlStatementID saveGold ;
static SqlStatementID saveLoot ;
// save money as 0 itemid data
if (loot->GetGoldAmount())
{
SqlStatement stmt = CharacterDatabase.CreateStatement(saveGold, "INSERT INTO item_loot (guid,owner_guid,itemid,amount,property) VALUES (?, ?, 0, ?, 0)");
stmt.PExecute(GetGUIDLow(), owner->GetGUIDLow(), loot->GetGoldAmount());
}
SqlStatement stmt = CharacterDatabase.CreateStatement(saveLoot, "INSERT INTO item_loot (guid,owner_guid,itemid,amount,property) VALUES (?, ?, ?, ?, ?)");
// save items and quest items (at load its all will added as normal, but this not important for item loot case)
LootItemList lootList;
loot->GetLootItemsListFor(owner, lootList);
for (LootItemList::const_iterator lootItr = lootList.begin(); lootItr != lootList.end(); ++lootItr)
{
LootItem* lootItem = *lootItr;
stmt.addUInt32(GetGUIDLow());
stmt.addUInt32(owner->GetGUIDLow());
stmt.addUInt32(lootItem->itemId);
stmt.addUInt8(lootItem->count);
stmt.addInt32(lootItem->randomPropertyId);
stmt.Execute();
}
}
}
if (m_lootState != ITEM_LOOT_NONE && m_lootState != ITEM_LOOT_TEMPORARY)
SetLootState(ITEM_LOOT_UNCHANGED);
SetState(ITEM_UNCHANGED);
}
示例4: SaveToDB
bool PlayerLogger::SaveToDB(PlayerLogMask mask, bool removeSaved, bool insideTransaction)
{
bool written = false;
uint64 serverStart = uint64(sWorld.GetStartTime());
for (uint8 i = 0; i < MAX_PLAYER_LOG_ENTITIES; ++i)
{
if ((mask & CalcLogMask(PlayerLogEntity(i))) == 0 || data[i] == NULL)
continue;
if (!insideTransaction)
CharacterDatabase.BeginTransaction();
written = true;
for (uint8 id = 0; id < data[i]->size(); ++id)
{
switch (PlayerLogEntity(i))
{
case PLAYER_LOG_DAMAGE_GET:
{
PlayerLogDamage info = *(PlayerLogDamage*)(&data[i]->at(id));
static SqlStatementID dmgGetStmt;
SqlStatement stmt = CharacterDatabase.CreateStatement(dmgGetStmt, "INSERT INTO playerlog_damage_get SET guid = ?, `time` = ?, aggressor = ?, isPlayer = ?, damage = ?, spell = ?");
stmt.addUInt32(playerGuid);
stmt.addUInt64(info.timestamp + serverStart);
stmt.addUInt32(info.GetId());
stmt.addBool(info.IsPlayer());
stmt.addInt32(info.damage);
stmt.addUInt16(info.spell);
stmt.Execute();
}
break;
case PLAYER_LOG_DAMAGE_DONE:
{
PlayerLogDamage info = *(PlayerLogDamage*)(&data[i]->at(id));
static SqlStatementID dmgDoneStmt;
SqlStatement stmt = CharacterDatabase.CreateStatement(dmgDoneStmt, "INSERT INTO playerlog_damage_done SET guid = ?, `time` = ?, victim = ?, isPlayer = ?, damage = ?, spell = ?");
stmt.addUInt32(playerGuid);
stmt.addUInt64(info.timestamp + serverStart);
stmt.addUInt32(info.GetId());
stmt.addBool(info.IsPlayer());
stmt.addInt32(info.damage);
stmt.addUInt16(info.spell);
stmt.Execute();
}
break;
case PLAYER_LOG_LOOTING:
{
PlayerLogLooting info = *(PlayerLogLooting*)(&data[i]->at(id));
static SqlStatementID lootStmt;
SqlStatement stmt = CharacterDatabase.CreateStatement(lootStmt, "INSERT INTO playerlog_looting SET guid = ?, `time`= ?, item = ?, sourceType = ?, sourceEntry = ?");
stmt.addUInt32(playerGuid);
stmt.addUInt64(info.timestamp + serverStart);
stmt.addUInt32(info.GetItemEntry());
stmt.addUInt8(uint8(info.GetLootSourceType()));
stmt.addUInt32(info.droppedBy);
stmt.Execute();
}
break;
case PLAYER_LOG_TRADE:
{
PlayerLogTrading info = *(PlayerLogTrading*)(&data[i]->at(id));
static SqlStatementID tradeStmt;
SqlStatement stmt = CharacterDatabase.CreateStatement(tradeStmt, "INSERT INTO playerlog_trading SET guid = ?, `time`= ?, itemEntry = ?, itemGuid = ?, aquired = ?, partner = ?");
stmt.addUInt32(playerGuid);
stmt.addUInt64(info.timestamp + serverStart);
stmt.addUInt32(info.GetItemEntry());
stmt.addUInt32(info.itemGuid);
stmt.addBool(info.IsItemAquired());
stmt.addUInt16(info.partner);
stmt.Execute();
}
break;
case PLAYER_LOG_KILL:
{
PlayerLogKilling info = *(PlayerLogKilling*)(&data[i]->at(id));
static SqlStatementID killStmt;
SqlStatement stmt = CharacterDatabase.CreateStatement(killStmt, "INSERT INTO playerlog_killing SET guid = ?, `time`= ?, iskill = ?, entry = ?, victimGuid = ?");
stmt.addUInt32(playerGuid);
stmt.addUInt64(info.timestamp + serverStart);
stmt.addBool(info.IsKill());
stmt.addUInt32(info.GetUnitEntry());
stmt.addUInt32(info.unitGuid);
stmt.Execute();
}
break;
case PLAYER_LOG_POSITION:
{
PlayerLogPosition info = *(PlayerLogPosition*)(&data[i]->at(id));
static SqlStatementID posStmt;
SqlStatement stmt = CharacterDatabase.CreateStatement(posStmt, "INSERT INTO playerlog_position SET guid = ?, `time`= ?, map = ?, posx = ?, posy = ?, posz = ?");
stmt.addUInt32(playerGuid);
stmt.addUInt64(info.timestamp + serverStart);
stmt.addUInt16(info.map);
stmt.addFloat(info.x);
stmt.addFloat(info.y);
stmt.addFloat(info.z);
stmt.Execute();
}
break;
case PLAYER_LOG_PROGRESS:
{
//.........这里部分代码省略.........