/** * \brief 从数据库中加载争夺目标记录 * \return true 加载成功 */ bool CDareRecordM::load() { DBFieldSet* dareRecord = SessionService::metaData->getFields("DARERECORD"); if (dareRecord) { connHandleID handle = SessionService::dbConnPool->getHandle(); if ((connHandleID)-1 == handle) { Zebra::logger->error("不能获取数据库句柄"); return false; } DBRecordSet* recordset = NULL; DBRecord rec; rec.put("daretime","DESC"); if ((connHandleID)-1 != handle) { recordset = SessionService::dbConnPool->exeSelect(handle,dareRecord,NULL,NULL,&rec,100); } SessionService::dbConnPool->putHandle(handle); if (recordset) { for (DWORD i=0; i<recordset->size(); i++) { DBRecord* rec = recordset->get(i); CDareRecord* pDareRecord = new CDareRecord(); if (pDareRecord) { pDareRecord->init(rec); } vDareRecord.push_back(pDareRecord); } SAFE_DELETE(recordset) } } else {
bool CAlly::deleteMeFromDB() { DBRecord where; std::ostringstream oss; oss << "countryid='" << this->dwCountryID << "'"; where.put("countryid",oss.str()); oss.str(""); oss << "allycountryid='" << this->dwAllyCountryID << "'"; where.put("allycountryid",oss.str()); connHandleID handle = SessionService::dbConnPool->getHandle(); if ((connHandleID)-1 == handle) { Zebra::logger->error("不能获取数据库句柄"); return false; } DBFieldSet* ally = SessionService::metaData->getFields("ALLY"); if (ally) { SessionService::dbConnPool->exeDelete(handle,ally,&where); Zebra::logger->info("[国家联盟]: %s,%s 解除联盟关系", CCountryM::getMe().find(this->dwCountryID)->name, CCountryM::getMe().find(this->dwAllyCountryID)->name); this->refreshAlly(true); this->refreshAllyToAllUser(true); } else { Zebra::logger->error("国家联盟数据删除失败,ALLY表不存在"); SessionService::dbConnPool->putHandle(handle); return false; } SessionService::dbConnPool->putHandle(handle); return true; }
bool CAlly::insertDatabase() { DBRecord rec; rec.put("countryid",this->dwCountryID); rec.put("allycountryid",this->dwAllyCountryID); rec.put("createtime",this->dwCreateTime); rec.put("frienddegree",this->dwFriendDegree); DBFieldSet* ally = SessionService::metaData->getFields("ALLY"); if (ally) { connHandleID handle = SessionService::dbConnPool->getHandle(); if ((connHandleID)-1 == handle) { Zebra::logger->error("不能获取数据库句柄"); return false; } else { SessionService::dbConnPool->exeInsert(handle,ally,&rec); Zebra::logger->info("[国家联盟]: %s,%s 建立联盟关系", CCountryM::getMe().find(this->dwCountryID)->name, CCountryM::getMe().find(this->dwAllyCountryID)->name); } SessionService::dbConnPool->putHandle(handle); } else { Zebra::logger->error("国家联盟数据新建失败,ALLY表不存在"); return false; } return true; }
bool Top100::init() { DBFieldSet* fs = MiniService::metaData->getFields("MINIGAME"); if (fs) { connHandleID handle = MiniService::dbConnPool->getHandle(); if ((connHandleID)-1 == handle) { Xlogger->error("Top100::init()不能获取数据库句柄"); return false; } DBRecord order; order.put("score","desc"); DBRecordSet *recordset = MiniService::dbConnPool->exeSelect(handle,fs,NULL,NULL,&order,200); DWORD count=0; if (recordset) { for (DWORD i=0; i<recordset->size() && count<120; i++) { DBRecord* rec = recordset->get(i); Cmd::MiniUserData d; strncpy(d.name,(const char*)rec->get("name"),MAX_NAMESIZE-1); d.id = rec->get("charid"); d.countryID = rec->get("country"); d.face = rec->get("face"); d.score.gameType = rec->get("gametype"); d.score.win = rec->get("win"); d.score.lose = rec->get("lose"); d.score.draw = rec->get("draw"); d.score.score = rec->get("score"); if (d.score.win||d.score.lose||d.score.draw||d.score.score) { top100.push_back(d); Xlogger->debug("Top100 %s(%u) score=%d",d.name,d.id,d.score.score); } } SAFE_DELETE(recordset) } MiniService::dbConnPool->putHandle(handle); return true; } return false; }