当前位置: 首页>>代码示例>>C++>>正文


C++ Query::Execute方法代码示例

本文整理汇总了C++中Query::Execute方法的典型用法代码示例。如果您正苦于以下问题:C++ Query::Execute方法的具体用法?C++ Query::Execute怎么用?C++ Query::Execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Query的用法示例。


在下文中一共展示了Query::Execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Store

bool GVDBBulletin::Store (GVdb * db, hDB handle)
{
	wxASSERT (m_turn != -1);

	SQLiteFile* sql = db->GetSQL(handle);
	if(!sql) {
		return false;
	}

	Query q = sql->GetQuery();

	q << "DELETE FROM bulletins WHERE turn=" << m_turn;
	if (!q.Execute()) {
		return false;
	}

	for (unsigned int i = 0; i < m_bulletins.GetCount (); i++) {
		wxString bulletin = m_bulletins[i];
		GVdb::EscapeSQL(bulletin);
		q << "INSERT INTO bulletins VALUES(" << m_turn << ", " << i
			<< ", \'" << bulletin.c_str() << "\')";

		if (!q.Execute()) {
			return false;
		}

	}
	return true;
}
开发者ID:scumola,项目名称:galaxyview,代码行数:29,代码来源:GVDBBulletin.cpp

示例2: NewGame

bool GVFrame::NewGame (wxString gamename, wxString turn0, wxString type)
{
	wxFileConfig *cf = (wxFileConfig *)wxConfigBase::Get (false);

	// create database
	wxString turnDir = cf->Read (_("/") + gamename + _("/GameDir"), "");
	if (turnDir.IsEmpty ()) {
		// GameDirectory is Empty
		return false;
	}

	// get game directory
	wxString gameDir = cf->Read(_T("/GalaxyView/GameDirectory"), "");
	if(gameDir.IsEmpty()) {
		return false;
	}

	// create turn directory if it doesnt exist
	if (!::wxDirExists (turnDir)) {
		::wxMkdir (turnDir);
	}

	// create game directory if it doesn't exist
	if(!::wxDirExists(gameDir)) {
		::wxMkdir(gameDir);
	}

	wxString dbfilename = gameDir + _("/") + gamename + _(".gdf"); 
	m_currentDB = m_db->Open (gamename, dbfilename);

	long game_init = cf->Read (_("/") + gamename + _("/Initialized"), 0L);
	if (!game_init) {
		// TODO: Database Init.
		GVApp::DBInit (m_db, m_currentDB);

		// Set initialized = 1
		cf->Write (_("/") + gamename + _("/Initialized"), 1L);

		// set show as active
		cf->Write (_("/") + gamename + _("/Active"), 1L);

		::wxSetCursor (*wxHOURGLASS_CURSOR);

		if(type=="GalaxyNG") {

			// Parse First Report - TODO: game types
			GVGalaxyNGReport* p = new GVGalaxyNGReport;

			if (p->ParseReport(m_db, m_currentDB, turn0)) {
				wxLogMessage (_T ("Turn Imported Into Database"));
			}
			else {
				wxLogMessage (_T ("Error Parsing"));
			}

			// Now Write additional data to the database (preferencesgame)
			SQLiteFile* sql = m_db->GetSQL(m_currentDB);
			if(!sql) return false;

			Query q = sql->GetQuery();

			// If there are already settings delete them
			q << "SELECT * FROM preferencesgame";
			Result res = q.Store();
			if(!res.Empty()) {
				q << "DELETE * FROM preferencesgame";
				q.Execute();
			}

			GVApp::GetGalaxy()->SetDatabase(m_db, m_currentDB);

			GVGalaxyNGFeatures* f = p->GetFeatures();

			GVGameData settings;
			settings.password = p->GetPassword();
			settings.gametype = "GalaxyNG";
			settings.gamename = p->GetGamename();
			settings.homeplanesnum = 0; /* TODO: Read from dialog */
			settings.homeplanetssize = ""; /* TODO: Read from dialog */
			settings.racename = p->GetPlayerRace();
			settings.size = f->size;

			GVApp::GetGalaxy()->GetGame()->Save(&settings);
			if(settings.valid) {
				wxLogMessage("Updated Preferences");
			} else {
				wxLogMessage("Failed to Update Preferences");
			}

			m_currentTurn = p->GetTurn();

			GVApp::GetGalaxy()->LoadTurn(m_currentTurn);
			m_map->SetMapSize(settings.size);
			m_map->SetTurn(m_currentTurn);

			delete p;

		} else {
			wxMessageBox("Gametype " + type + " not supported yet.", "Sorrry :(");
			return false;
//.........这里部分代码省略.........
开发者ID:scumola,项目名称:galaxyview,代码行数:101,代码来源:GVFrame.cpp


注:本文中的Query::Execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。