本文整理汇总了C++中DBResultRow::GetInt64方法的典型用法代码示例。如果您正苦于以下问题:C++ DBResultRow::GetInt64方法的具体用法?C++ DBResultRow::GetInt64怎么用?C++ DBResultRow::GetInt64使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBResultRow
的用法示例。
在下文中一共展示了DBResultRow::GetInt64方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load
bool AttributeMap::Load()
{
/* First, we load default attributes values using existing attribute system */
DgmTypeAttributeSet *attr_set = sDgmTypeAttrMgr.GetDmgTypeAttributeSet( mItem.typeID() );
if (attr_set == NULL)
return false;
DgmTypeAttributeSet::AttrSetItr itr = attr_set->attributeset.begin();
for (; itr != attr_set->attributeset.end(); itr++)
SetAttribute((*itr)->attributeID, (*itr)->number, false);
/* Then we load the saved attributes from the db, if there are any yet, and overwrite the defaults */
DBQueryResult res;
if(mDefault)
{
if(!sDatabase.RunQuery(res, "SELECT * FROM entity_default_attributes WHERE itemID='%u'", mItem.itemID())) {
sLog.Error("AttributeMap (DEFAULT)", "Error in db load query: %s", res.error.c_str());
return false;
}
}
else
{
if(!sDatabase.RunQuery(res, "SELECT * FROM entity_attributes WHERE itemID='%u'", mItem.itemID())) {
sLog.Error("AttributeMap", "Error in db load query: %s", res.error.c_str());
return false;
}
}
DBResultRow row;
int amount = res.GetRowCount();
for (int i = 0; i < amount; i++)
{
EvilNumber attr_value;
res.GetRow(row);
uint32 attributeID = row.GetUInt(1);
if (!row.IsNull(2))
attr_value = row.GetInt64(2);
else
attr_value = row.GetDouble(3);
SetAttribute(attributeID, attr_value, false);
}
return true;
/*
/// EXISTING AttributeMap::Load() function
DBQueryResult res;
if(!sDatabase.RunQuery(res,"SELECT * FROM entity_attributes WHERE itemID='%u'", mItem.itemID())) {
sLog.Error("AttributeMap", "Error in db load query: %s", res.error.c_str());
return false;
}
DBResultRow row;
int amount = res.GetRowCount();
// Right now, assume that we need to load all attributes with default values from dgmTypeAttributes table
// IF AND ONLY IF the number of attributes pulled from the entity_attributes table for this item is ZERO:
if( amount > 0 )
{
// This item was found in the 'entity_attributes' table, so load all attributes found there
// into the Attribute Map for this item:
for (int i = 0; i < amount; i++)
{
res.GetRow(row);
EvilNumber attr_value;
uint32 attributeID = row.GetUInt(1);
if ( !row.IsNull(2) )
attr_value = row.GetInt64(2);
else if( !row.IsNull(3) )
attr_value = row.GetDouble(3);
else
sLog.Error( "AttributeMap::Load()", "Both valueInt and valueFloat fields of this (itemID,attributeID) = (%u,%u) are NULL.", row.GetInt(0), attributeID );
SetAttribute(attributeID, attr_value, false);
//Add(attributeID, attr_value);
}
}
else
{
// This item was NOT found in the 'entity_attributes' table, so let's assume that
// this item was just created.
// 1) Get complete list of attributes with default values from dgmTypeAttributes table using the item's typeID:
DgmTypeAttributeSet *attr_set = sDgmTypeAttrMgr.GetDmgTypeAttributeSet( mItem.typeID() );
if (attr_set == NULL)
return false;
DgmTypeAttributeSet::AttrSetItr itr = attr_set->attributeset.begin();
// Store all these attributes to the item's AttributeMap
for (; itr != attr_set->attributeset.end(); itr++)
{
SetAttribute((*itr)->attributeID, (*itr)->number, false);
//Add((*itr)->attributeID, (*itr)->number);
}
//.........这里部分代码省略.........