本文整理汇总了C++中QueryResult::next方法的典型用法代码示例。如果您正苦于以下问题:C++ QueryResult::next方法的具体用法?C++ QueryResult::next怎么用?C++ QueryResult::next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryResult
的用法示例。
在下文中一共展示了QueryResult::next方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void RoItemDB::init(short max_id)
{
if (_inited)
return;
_inited = true;
_max_id = max_id;
_items = new RoDBItem[_max_id];
// Do it for ourself.
string sql = "SELECT `id`,`name_english`,`type`,`price_buy`,`price_sell`,`weight`,`attack`,`defence`,`range`,`slots`,`equip_jobs`,`equip_upper`,`equip_genders`,`equip_locations`,`weapon_level`,`equip_level`,`refineable`,`view` FROM `%s`";
QueryResult* res = DatabaseMgr::get_singleton().query(sql.c_str(),
RO_ITEM_DB_TB);
if (!res)
{
LogError("RO_ITEM_DB", "Empty item db");
return;
}
size_t count = res->get_row_size();
size_t i = 0;
for (; i < count; ++i)
{
Field* f = res->fetch();
if (!fetch_item(f))
break;
res->next();
}
LogSuccess("RO_ITEM_DB", "%d items has been loaded!!", i);
res->Delete();
return;
}
示例2: load_hotkey
bool RoSql::load_hotkey(int char_id, std::vector<RoCharHotKey>& keys)
{
keys.clear();
string sql = "SELECT `hotkey`, `type`, `itemskill_id`, `skill_lvl` FROM `%s` WHERE `char_id`=%d LIMIT %d";
QueryResult* res = DatabaseMgr::get_singleton().query(sql.c_str(), RO_HOTKEY_TB, char_id, MaxHotKeyCount);
if (res == NULL)
return true;;
size_t count = res->get_row_size();
for (size_t n = 0; n < count; ++n)
{
Field* f = res->fetch();
RoCharHotKey key;
key._id = f[0].get<int>();
key._type = f[1].get<uint16>();
key._lvl = f[2].get<uint16>();
keys.push_back(key);
res->next();
}
res->Delete();
return true;
}
示例3: load_friends
bool RoSql::load_friends(int char_id, std::vector<RoCharFriendInfo>& friends)
{
friends.clear();
string sql = "SELECT c.`account_id`, c.`char_id`, c.`name` FROM `%s` c LEFT JOIN `%s` f ON f.`friend_account` = c.`account_id` AND f.`friend_id` = c.`char_id` WHERE f.`char_id`=%d LIMIT %d";
QueryResult* res = DatabaseMgr::get_singleton().query(sql.c_str(), RO_CHAR_TB, RO_FRIEND_TB, char_id, MaxFriendCount);
if (res == NULL)
return true;
size_t count = res->get_row_size();
for (size_t n = 0; n < count; ++n)
{
Field* f = res->fetch();
RoCharFriendInfo fr;
fr._account_id = f[0].get<int>();
fr._char_id = f[1].get<int>();
fr._name = f[2].get<string>();
fr._nick_name = f[2].get<string>();
friends.push_back(fr);
res->next();
}
res->Delete();
return true;
}
示例4: load_skill
bool RoSql::load_skill(int char_id, std::vector<RoCharSkillInfo>& skills)
{
skills.clear();
string sql = "SELECT `id`, `lv` FROM `%s` WHERE `char_id`=%d LIMIT %d";
QueryResult* res = DatabaseMgr::get_singleton().query(sql.c_str(), RO_SKILL_TB, char_id, MaxSkillCount);
if (res == NULL)
return true;
size_t count = res->get_row_size();
for (size_t n = 0; n < count; ++n)
{
Field* f = res->fetch();
RoCharSkillInfo skill;
skill._id = f[0].get<int>();
skill._lvl = f[1].get<int>();
skill._flag = f[2].get<int>();
skills.push_back(skill);
res->next();
}
res->Delete();
return true;
}
示例5: load_cart
bool RoSql::load_cart(int char_id, std::vector<RoCharItem>& cart_items)
{
cart_items.clear();
string sql = "SELECT `id`, `nameid`, `amount`, `equip`, `identify`, `refine`, `attribute`, `expire_time`";
for (int i = 0; i <MaxSlotCount; ++i)
sql += ", `card" + conversion_cast<string>(i) + "`";
sql += " FROM `%s` WHERE `char_id`=%d LIMIT %d";
QueryResult* res = DatabaseMgr::get_singleton().query(sql.c_str(), RO_CART_TB, char_id, MaxCartCount);
if (res == NULL)
return true;
size_t count = res->get_row_size();
for (size_t n = 0; n < count; ++n)
{
Field* f = res->fetch();
RoCharItem info;
info._id = f[0].get<int>();
info._type = f[1].get<short>();
info._amount = f[2].get<short>();
info._equip = f[3].get<uint16>();
info._identify = f[4].get<char>();
info._refine = f[5].get<char>();
info._attrs = f[6].get<char>();
info._expire_time = f[7].get<unsigned int>();
cart_items.push_back(info);
res->next();
}
res->Delete();
return true;
}
示例6: load_chars
size_t RoSql::load_chars(int account_id, RoCharInfoBase*& result)
{
std::string sql = "SELECT `char_id`,`char_num`,`name`,`class`,`base_level`,`job_level`,`base_exp`,`job_exp`,`zeny`,`str`,`agi`,`vit`,`int`,`dex`,`luk`,`max_hp`,`hp`,`max_sp`,`sp`,`status_point`,`skill_point`,`option`,`karma`,`manner`,`hair`,`hair_color`,`clothes_color`,`weapon`,`shield`,`head_top`,`head_mid`,`head_bottom` FROM `%s` WHERE `account_id`='%d'";
QueryResult* res = DatabaseMgr::get_singleton().query(sql.c_str(),
RO_CHAR_TB, account_id);
if (!res)
return 0;
size_t count = res->get_row_size();
if (count == 0)
{
res->Delete();
return 0;
}
result = new RoCharInfoBase[count];
size_t i = 0;
for (; i < count; ++i)
{
Field* f = res->fetch();
if (!f)
break;
RoCharInfoBase* info =result + i;
info->_account_id = account_id;
if (!fetch_chars_info(f, *info))
break;
res->next();
}
res->Delete();
return i;
}