Example #1
0
	bool AliasEventQueryHash::ProcessQuery()
	{
		std::unique_ptr<SQLiteQuery> query = 
			aliasdb->NewQuery(L"SELECT * FROM alias WHERE hash=:hash");
		query->BindValue(":hash", hash);
		this->result = std::move(query->Execute());
		return true; // has result
	}
Example #2
0
	bool AliasEventQueryPlayer::ProcessQuery()
	{
		std::unique_ptr<SQLiteQuery> query = 
			aliasdb->NewQuery(L"SELECT * FROM alias WHERE name LIKE :wildcard ORDER BY hash,name");
		query->BindValue(":wildcard", player);
		this->result = std::move(query->Execute());
		return true;
	}
Example #3
0
	// -------------------------------------------------------------------
	// Interface with rest of Phasor.
	void Initialize()
	{
		try 
		{
			std::string alias_file = m_sprintf("%s\\alias.sqlite",
				NarrowString(g_DataDirectory).c_str());
			aliasdb.reset(new sqlite::SQLite(alias_file));

			std::unique_ptr<SQLiteQuery> query = aliasdb->NewQuery(
				L"CREATE TABLE IF NOT EXISTS alias (hash CHAR(32), name VARCHAR(20))");
			query->Execute();
		}
		catch (SQLiteError& error)
		{
			g_PhasorLog->print("Cannot create alias database, error '%s'", error.what());
			aliasdb.reset();
		}
	}
Example #4
0
	bool AliasEventAddPlayer::ProcessQuery()
	{
		std::unique_ptr<SQLiteQuery> query = 
			aliasdb->NewQuery(
			L"SELECT * FROM alias WHERE hash=:hash AND name=:name"
			);
		query->BindValue(":hash", hash);
		query->BindValue(":name", name);
		std::unique_ptr<SQLiteResult> result = query->Execute();

		if (result->size() == 0) {
			query->Reset(
				L"INSERT INTO alias (hash, name) VALUES(:hash,:name)");
			query->BindValue(":hash", hash);
			query->BindValue(":name", name);
			query->Execute();
		}
		return false; // no result
	}