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  //获取字符串

  • 相关阅读:
    makefile编写---单个子目录编译自动变量模板ok
    任务22:课程介绍 & 任务23:Http请求的处理过程
    任务20:DI初始化的源码解读 & 任务21:依赖注入的使用
    任务19:单元测试
    任务18:控制反转
    任务17:从UML角度来理解依赖
    任务16:介绍-
    任务15:配置框架设计浅析
    任务14:配置的热更新
    任务13:在Core Mvc中使用Options
  • 原文地址:https://www.cnblogs.com/needly/p/3757391.html
Copyright © 2011-2022 走看看