Example #1
0
    //-------------------------------------------------------------------------------------------
    MG::Bool ItemDBOp::updateItemDBInfo( DBDriver& driver, const U64& itemDBID, const ItemRecord* itemDBdata )
    {
        Char8 sql[1028] = {0};
        Str8 tempfathername;
        MGStrOp::toString( itemDBdata->fatherName, tempfathername ); 

        MGStrOp::sprintf(
            sql,
            1028, 
            "update itemdb_info set \
            itemdb_belong_id = %I64d, itemdb_belong_type = %d, itemdb_belong_pos = %d, itemdb_index = %d \
            , itemdb_father_name = '%s', itemdb_bind_type = %d, itemdb_curnum = %d, itemdb_curdurable = %d, itemdb_currepairnum = %d \
            , itemdb_curstrengthenlv = %d, itemdb_rand_appendid = %d, itemdb_strengthen_appendid = %d, itemdb_due_time = %I64d \
            , itemdb_character_id = %I64d   where item_id = %I64d",
            itemDBdata->itemBelongID, itemDBdata->itemBelongType, itemDBdata->belongPos, itemDBdata->slotIndex
            , tempfathername.c_str(), itemDBdata->bindType, itemDBdata->curNum, itemDBdata->curDurable, itemDBdata->curRepairNum
            , itemDBdata->curStrengthenLv, itemDBdata->randAppendID, itemDBdata->strengthenAppendID, itemDBdata->dueTime 
            , itemDBdata->characterId
            , itemDBID
            );

        DBQueryResultEx resEx = driver.query( sql, false );
        DBQueryResult* dbRes = *resEx;
        if ( dbRes  &&  dbRes->getResultType() != DBQuery_Result_INVALID )
        {  
            return true;
        }
        return false;
    }
Example #2
0
    //-------------------------------------------------------------------------------------------
    MG::Bool ItemDBOp::insertItemDB( DBDriver& driver, U64& itemDBID )
    {
        //插入
        Char8 sql[128] = {0};     

        MGStrOp::sprintf(
                        sql,
                        128, 
                        "insert into itemdb_info ()  values()" 
        );

        Bool result = false; 
        driver.queryLock();
        {
            DBQueryResultEx resEx = driver.query(sql);
            DBQueryResult* dbRes = *resEx;
            if ( dbRes  &&  dbRes->getResultType() != DBQuery_Result_INVALID )
            {  
                result = true;
                itemDBID = CommonGameDBOp::getLastInsertID( driver, false );
            }
        }
        driver.queryUnLock();
        return result;
    }
Example #3
0
    //-------------------------------------------------------------------------------------------
    MG::Bool ItemDBOp::getItemDB( DBDriver& driver, const U64& clanID, const ITEM_BELONG_TYPE& type, std::vector<ItemRecord>& recordList )
    {
        ItemRecord data;

        Char8 sql[128] = {0};
        MGStrOp::sprintf(sql,128,"select * from "ITEMDB_TABLE_NAME" where itemdb_belong_id = %I64d and itemdb_belong_type = %d",clanID, type);

        DBQueryResultEx resEx = driver.query(sql);
        DBQueryResult* res = *resEx;
        if ( res  &&  res->getResultType() != DBQuery_Result_INVALID  &&  res->getRowCount() > 0 )
        {
            Str16 wName;
            Str   tempStr;

            I32 nRow = res->getRowCount();
            for ( I32 i=0; i<nRow; i++ )
            {
                memset(&data, 0, sizeof(data));
                U32 nCol = 0;
                
                
               // data.itemDBID                    = res->getFieldData( i, nCol++ )->ulonglongData;
                data.characterId                 = res->getFieldData( i, nCol++ )->ulonglongData;
                data.itemTempID                  = res->getFieldData( i, nCol++ )->uintData;
                data.itemBelongID                = res->getFieldData( i, nCol++ )->ulonglongData;
                data.itemBelongType              = (ITEM_BELONG_TYPE)( res->getFieldData( i, nCol++ )->ubyteData );
                data.belongPos                   = (ITEM_SITE_TYPE)( res->getFieldData( i, nCol++ )->ubyteData );
                data.slotIndex                       = res->getFieldData( i, nCol++ )->uintData;
                res->getFieldData(i, nCol++, tempStr);
                MGStrOp::toString(tempStr.c_str(), wName);
                memcpy(data.fatherName, wName.c_str(), sizeof(MAX_CHARACTER_NAME_LEN));
                data.bindType                    = (ITEM_BIND_TYPE)( res->getFieldData( i, nCol++ )->ubyteData );
                data.curNum                      = res->getFieldData( i, nCol++ )->uintData;
                data.curDurable                  = res->getFieldData( i, nCol++ )->uintData;
                data.curRepairNum                = res->getFieldData( i, nCol++ )->uintData;
                data.curStrengthenLv             = res->getFieldData( i, nCol++ )->uintData;
                data.randAppendID                = res->getFieldData( i, nCol++ )->uintData;
                data.strengthenAppendID          = res->getFieldData( i, nCol++ )->uintData;
                //时间
                /*data.dueTime                     = res->getFieldData( i, nCol++ )->ulonglongData;
                data.bornTime                    = res->getFieldData( i, nCol++ )->ulonglongData;
                data.delTime                     = res->getFieldData( i, nCol++ )->ulonglongData;
                data.updateTime                  = res->getFieldData( i, nCol++ )->ulonglongData;*/
                

                recordList.push_back(data);
            }
            return true;
        }

        return false;
    }
Example #4
0
    //-------------------------------------------------------------------------------------------
    MG::Bool ItemDBOp::updateItemDBNum( DBDriver& driver, const U64& itemDBID, const U8 num )
    {
        Char8 sql[128] = {0};
        MGStrOp::sprintf(
            sql,
            128, 
            "update itemdb_info set itemdb_curnum = %d where item_id = %I64d",
            num,
            itemDBID
            );

        DBQueryResultEx resEx = driver.query( sql, false );
        DBQueryResult* dbRes = *resEx;
        if ( dbRes  &&  dbRes->getResultType() != DBQuery_Result_INVALID )
        {  
            return true;
        }
        return false;
    }
Example #5
0
    //-------------------------------------------------------------------------------------------
    MG::Bool ItemDBOp::updateItemDBIndex(DBDriver& driver, const U64& itemDBID, const U32& Index, const U8& belongPos)
    {
        Char8 sql[128] = {0};
        MGStrOp::sprintf(
            sql,
            128, 
            "update itemdb_info set itemdb_index = %d, itemdb_belong_pos = %d where item_id = %I64d",
            Index,
            belongPos,
            itemDBID
            );

        DBQueryResultEx resEx = driver.query( sql, false );
        DBQueryResult* dbRes = *resEx;
        if ( dbRes  &&  dbRes->getResultType() != DBQuery_Result_INVALID )
        {  
            return true;
        }
        return false;
    }
Example #6
0
    Bool TroopDBOp::checkOrCreateTroopTable( DBDriver& driver )
    {
        static Colume troopColumn[] = 
        {      		
            {"troop_master_id",			"BIGINT",			"0"},				//根据以上主人类型,记录的Id( 或regionID或clanID )
            {"troop_template_id",		"INT",		        "0"},				//军队模板id	
            {"troop_master_type",	    "INT",		        "0"},				//"军队主人的类型,   
            {"troop_life_type",			"INT",		        "0"},				//军队存活类型,
            {"troop_lvl",               "INT",              "0"},               //军队等级
            {"troop_exp",			    "INT",			    "0"},				//军队当前经验度,最大为1000
            {"troop_num",		        "INT",			    "0"},				//军队当前兵数		
            {"troop_loyal",		        "INT",			    "0"},				//军队当前忠诚度,最大为1000
            {"troop_weapon",			"INT",			    "0"},				//军队当前武装度,最大为1000           
            {"troop_wound",			    "INT",			    "0"},				//军队当前伤兵率,最大为1000            
        };

        DBQueryResultEx resEx = driver.query("CREATE TABLE IF NOT EXISTS "TROOP_TABLE_NAME" (troop_id BIGINT NOT NULL AUTO_INCREMENT,PRIMARY KEY(troop_id))");
        DBQueryResult* pRes = *resEx;
        if (!pRes ||(pRes && pRes->getResultType() == DBQuery_Result_INVALID))
        {
            return false;
        }

        Bool res1 = driver.addColume(TROOP_TABLE_NAME,troopColumn,sizeof(troopColumn)/sizeof(Colume));
        if (!res1)
        {
            return false;
        }
        //加索引
        if ( !( *( driver.query("ALTER TABLE "TROOP_TABLE_NAME" ADD INDEX  troopmaster (troop_master_id, troop_master_type)") ) ) )
        {
            return false;
        }

        return true;
    }