zoukankan      html  css  js  c++  java
  • T端数据库使用

    --------SQL DEMO  01--------

    void LFGMgr::LoadRequiredLevels()
    {
        uint32 oldMSTime = getMSTime();
    
        m_RequiredIlvlMap.clear();
    
        // ORDER BY is very important for GetRandomDungeonReward!
        QueryResult result = WorldDatabase.Query("SELECT ID, ItemLevel FROM lfg_required_ilevel ORDER BY ID");
    
        if (!result)
        {
            sLog->outError(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 lfg required item levels for instances");
            return;
        }
    
        uint32 count = 0;
    
        Field* fields = NULL;
        do
        {
            fields = result->Fetch();
            uint32 dungeonId = fields[0].GetUInt32();
            uint32 itemLevel = fields[1].GetUInt32();
    
            const LFGDungeonEntry* dungeon = sLFGDungeonStore.LookupEntry(dungeonId);
            if (!sLFGDungeonStore.LookupEntry(dungeonId))
            {
                sLog->outError(LOG_FILTER_SQL, "Dungeon %u specified in table `lfg_required_ilevel` does not exist!", dungeonId);
                continue;
            }
    
            m_RequiredIlvlMap.insert(LfgRequiredIlvlMap::value_type(dungeonId, itemLevel));
            ++count;
        } while (result->NextRow());
    
        sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u lfg required itemlevels in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
    }


     

    ------SQL DEMO 02------

    void LFGMgr::LoadRequiredLevels()
    {
        uint32 oldMSTime = getMSTime();
    
        m_RequiredIlvlMap.clear();
    
        // ORDER BY is very important for GetRandomDungeonReward!
        QueryResult result = WorldDatabase.Query("SELECT ID, ItemLevel FROM lfg_required_ilevel ORDER BY ID");
    
        if (!result)
        {
            sLog->outError(LOG_FILTER_SERVER_LOADING, ">> Loaded 0 lfg required item levels for instances");
            return;
        }
    
        uint32 count = 0;
    
        Field* fields = NULL;
        do
        {
            fields = result->Fetch();
            uint32 dungeonId = fields[0].GetUInt32();
            uint32 itemLevel = fields[1].GetUInt32();
    
            const LFGDungeonEntry* dungeon = sLFGDungeonStore.LookupEntry(dungeonId);
            if (!sLFGDungeonStore.LookupEntry(dungeonId))
            {
                sLog->outError(LOG_FILTER_SQL, "Dungeon %u specified in table `lfg_required_ilevel` does not exist!", dungeonId);
                continue;
            }
    
            m_RequiredIlvlMap.insert(LfgRequiredIlvlMap::value_type(dungeonId, itemLevel));
            ++count;
        } while (result->NextRow());
    
        sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Loaded %u lfg required itemlevels in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
    }

     ------String Demo 01------

    //void World::SendWorldText(int32 string_id, ...)

    std::string str = "[|cffff0000";    //"|cfff0ff00[世界][|r"
            std::string name = handler->GetSession()->GetPlayer()->GetName();
            str += name;
            str += "|r]:";
            str += args;
            sWorld->SendWorldText(1000000, str, args);

    ------.conf Demo 01------

    ConfigMgr::GetStringDefault  //获取字符串

  • 相关阅读:
    Android 6.0以上动态获取权限
    大学实验3指导:利用单链表实现A-B
    大学课程实验2指导-二叉树的建立与遍历
    大学实验1 哈夫曼编码
    大学java教案之MySQL安装图解
    DrawableAnimation小练习
    Android学习第7天
    Android学习第6天
    There's no Qt version assigned to this project for platform Win32
    OpenBCI 开发环境配置
  • 原文地址:https://www.cnblogs.com/needly/p/3757391.html
Copyright © 2011-2022 走看看