本文整理汇总了C++中QueryResult_AutoPtr::GetFieldCount方法的典型用法代码示例。如果您正苦于以下问题:C++ QueryResult_AutoPtr::GetFieldCount方法的具体用法?C++ QueryResult_AutoPtr::GetFieldCount怎么用?C++ QueryResult_AutoPtr::GetFieldCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryResult_AutoPtr
的用法示例。
在下文中一共展示了QueryResult_AutoPtr::GetFieldCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateDumpString
std::string CreateDumpString(char const* tableName, QueryResult_AutoPtr result)
{
if (!tableName || !result) return "";
std::ostringstream ss;
ss << "INSERT INTO "<< _TABLE_SIM_ << tableName << _TABLE_SIM_ << " VALUES (";
Field *fields = result->Fetch();
for (uint32 i = 0; i < result->GetFieldCount(); ++i)
{
if (i == 0) ss << "'";
else ss << ", '";
std::string s = fields[i].GetCppString();
CharacterDatabase.escape_string(s);
ss << s;
ss << "'";
}
ss << ");";
return ss.str();
}
示例2: DumpTable
// Writing - High-level functions
bool PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tableFrom, char const*tableTo, DumpTableType type)
{
GUIDs const* guids = NULL;
char const* fieldname = NULL;
switch (type)
{
case DTT_ITEM:
fieldname = "guid";
guids = &items;
break;
case DTT_ITEM_GIFT:
fieldname = "item_guid";
guids = &items;
break;
case DTT_PET:
fieldname = "owner";
break;
case DTT_PET_TABLE:
fieldname = "guid";
guids = &pets;
break;
case DTT_MAIL:
fieldname = "receiver";
break;
case DTT_MAIL_ITEM:
fieldname = "mail_id";
guids = &mails;
break;
default:
fieldname = "guid";
break;
}
// for guid set stop if set is empty
if (guids && guids->empty())
return true; // nothing to do
// setup for guids case start position
GUIDs::const_iterator guids_itr;
if (guids)
guids_itr = guids->begin();
do
{
std::string wherestr;
if (guids) // set case, get next guids string
wherestr = GenerateWhereStr(fieldname,*guids,guids_itr);
else // not set case, get single guid string
wherestr = GenerateWhereStr(fieldname,guid);
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT * FROM %s WHERE %s", tableFrom, wherestr.c_str());
if (!result)
return true;
do
{
// collect guids
switch (type)
{
case DTT_INVENTORY:
StoreGUID(result,3,items);
break; // item guid collection (character_inventory.item)
case DTT_PET:
StoreGUID(result,0,pets);
break; // pet petnumber collection (character_pet.id)
case DTT_MAIL:
StoreGUID(result,0,mails); // mail id collection (mail.id)
case DTT_MAIL_ITEM:
StoreGUID(result,1,items);
break; // item guid collection (mail_items.item_guid)
case DTT_CHARACTER:
{
if (result->GetFieldCount() <= 67) // avoid crashes on next check
return true;
if (result->Fetch()[67].GetUInt32()) // characters.deleteInfos_Account - if filled error
return false;
break;
}
default:
break;
}
dump += CreateDumpString(tableTo, result);
dump += "\n";
}
while (result->NextRow());
}
while (guids && guids_itr != guids->end()); // not set case iterate single time, set case iterate for all guids
return true;
}