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


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

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


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

示例1: removeFolderChildren

// Recursive Function
void _ftpEntry::removeFolderChildren( size_t folderID ) {
    Connection                     *sqlConnect = dbConnect();
    bool							isDone						= false;
	Query							serverQuery					= sqlConnect->query();
	StoreQueryResult				serverResults;
	StoreQueryResult::iterator		storeQueryIT;
    size_t                          ID;

    // Find all folders that parent us
    serverQuery << "select * from ServerFolders where parentID = "      << quote << folderID;
    serverQuery.execute();

    // 
    for(storeQueryIT = serverResults.begin(); storeQueryIT != serverResults.end(); storeQueryIT++ ) {
        
        // Remove all children from this parent
        ID = (size_t) (*storeQueryIT)["folderID"];
        removeFolderChildren( ID );
        
        // Now remove the parent
        serverQuery.str("");
	    serverQuery << "delete from ServerFolders where folderID = "	<< quote << ID;
        serverQuery.execute();
    }

    delete sqlConnect;
}
开发者ID:segrax,项目名称:KiLLARMY,代码行数:28,代码来源:ftpEntry.cpp

示例2: DeleteGame

void GameModel::DeleteGame() {
	using namespace ManaCraft::Database;

	try {

		this->teams->DeleteTeams();

		Query query = DatabaseAPI::getQuery();
		query.clear();
		query << "DELETE FROM Game WHERE ID = " << mysqlpp::quote << this->id;
		query.execute();

		query = DatabaseAPI::getQuery();
		query.clear();
		query << "DELETE FROM Game_Teams WHERE ID = " << mysqlpp::quote << this->id;
		query.execute();

		query = DatabaseAPI::getQuery();
		query.clear();
		query << "DELETE FROM Game_Player_Towers WHERE ID = " << mysqlpp::quote << this->id;
		query.execute();
	}
	catch (mysqlpp::BadConversion e) {
		std::cout << e.what() << "\n";
	}
	catch (mysqlpp::BadIndex e) {
		std::cout << e.what() << "\n";
	}
	catch (Exception e) {
		throw e;
	}
}
开发者ID:rnrobson,项目名称:game440_01_2014,代码行数:32,代码来源:GameModel.cpp

示例3: testDelete

void TestDatabase::testDelete()
{
	DatabaseAPI::connectToDatabase();

	Query query = DatabaseAPI::getQuery();
	query.clear();
	query << "DELETE FROM Test_Table WHERE ID = 1";
	query.execute();

	query = DatabaseAPI::getQuery();
	query.clear();
	query << "DELETE FROM Test_Table WHERE ID = 2";
	query.execute();
}
开发者ID:rnrobson,项目名称:game440_01_2014,代码行数:14,代码来源:TestDatabase.cpp

示例4: close

void SaslConnection::close()
{
    Endpoint client = peer();
    Connection::close();

    if ( !u || logged ||
         !client.valid() || client.protocol() == Endpoint::Unix )
        return;

    logged = true;

    Query * q = new Query(
        "insert into connections "
        "(username,address,port,mechanism,authfailures,"
        "syntaxerrors,started_at,ended_at,userid) "
        "values ($1,$2,$3,$4,$5,$6,"
        "$7::interval + 'epoch'::timestamptz,"
        "$8::interval + 'epoch'::timestamptz,$9)", 0
    );

    q->bind( 1, u->login() );
    q->bind( 2, client.address() );
    q->bind( 3, client.port() );
    q->bind( 4, m );
    q->bind( 5, af );
    q->bind( 6, sf );
    q->bind( 7, s );
    q->bind( 8, (uint)time( 0 ) );
    q->bind( 9, u->id() );
    q->execute();

}
开发者ID:aox,项目名称:aox,代码行数:32,代码来源:saslconnection.cpp

示例5: insert_contact

/**
 * Insert a contact into the database.
 *
 * Demonstrates:
 * - use of a sequence
 * - opening of a table
 * - insert mode
 * - assigning data to a row
 * - posting data to the database
 * - closing a table
 * - inserting data into a BLOB field
 */
db_uint PhoneBook::insert_contact(const wchar_t *name, db_uint ring_id, const char *picture_name)
{
    Query       q;
    Sequence    id_sequence;
    db_uint         id;

    id_sequence.open(db, "contact_id");
    id_sequence.get_next_value(id);

    q.prepare(db,
        "insert into contact (id, name, ring_id, picture_name) "
        "  values ($<integer>0, $<nvarchar>1, $<integer>2, $<varchar>3) ");
    q.param(0) = id;
    q.param(1) = name;
    q.param(2) = ring_id;
    q.param(3) = picture_name;
    if  (DB_SUCCESS(print_error(q.execute(), q))) {
        //---------------------------------------------------------------
        // Insert the BLOB field
        //---------------------------------------------------------------
        update_contact_picture(id, picture_name);
    } else {
        //---------------------------------------------------------------
        // Error returned from execute
        //---------------------------------------------------------------
        id = 0;
    }

    return id;
}
开发者ID:ittia,项目名称:phone-book-cpp,代码行数:42,代码来源:phonebook_sql.cpp

示例6: SaveGame

void GameModel::SaveGame()
{
	using namespace ManaCraft::Database;

	// Game Table
	Query query = DatabaseAPI::getQuery();
	query.clear();
	query << "SELECT * FROM Game WHERE ID = " << mysqlpp::quote << id;

	if (UseQueryResult result = query.use()) {
		if (Row row = result.fetch_row()) {
			DeleteGame();
		}
	}

	try {
		query = DatabaseAPI::getQuery();
		query.clear();
		query << "INSERT INTO Game VALUES(" << mysqlpp::quote << id << ", " << mysqlpp::quote << "Another Game" << ")";
		query.execute();

		teams->SaveTeams(id);
	}
	catch (mysqlpp::BadConversion e) {
		std::cout << e.what() << "\n";
	}
	catch (mysqlpp::BadIndex e) {
		std::cout << e.what() << "\n";
	}
	catch (Exception e) {
		throw e;
	}

}
开发者ID:rnrobson,项目名称:game440_01_2014,代码行数:34,代码来源:GameModel.cpp

示例7: Deliverator

 Deliverator( Injectee * message,
              const UString & mailbox, const EString & user )
     : q( 0 ), i( 0 ), m( message ), mbn( mailbox ), un( user ),
       p( 0 ), mb( 0 )
 {
     Allocator::addEternal( this, "deliver object" );
     q = new Query( "select al.mailbox, n.name as namespace, u.login "
                    "from aliases al "
                    "join addresses a on (al.address=a.id) "
                    "left join users u on (al.id=u.alias) "
                    "left join namespaces n on (u.parentspace=n.id) "
                    "where (lower(a.localpart)=$1 and lower(a.domain)=$2) "
                    "or (lower(u.login)=$3)", this );
     if ( user.contains( '@' ) ) {
         int at = user.find( '@' );
         q->bind( 1, user.mid( 0, at ).lower() );
         q->bind( 2, user.mid( at + 1 ).lower() );
     }
     else {
         q->bindNull( 1 );
         q->bindNull( 2 );
     }
     q->bind( 3, user.lower() );
     q->execute();
 }
开发者ID:copernicus,项目名称:aox,代码行数:25,代码来源:deliver.cpp

示例8: saveRemark

void ShotResult::saveRemark()
{
	int index = mtw_Shotremark->currentRow();
	qDebug("Index:%d",index);
	if (index < 0) return;
	QTableWidgetItem *pItem = mtw_Shotremark->item(index, WRITER);
	string strwriter = pItem->text().toStdString();
	pItem = mtw_Shotremark->item(index, REMARK);
	string strremark = pItem->text().toStdString();
	try {
		sql_datetime wdate;
		QDateTime datetime = QDateTime::currentDateTime();
		wdate.year = datetime.date().year();
		wdate.month = datetime.date().month();
		wdate.day= datetime.date().day();
		wdate.hour=datetime.time().hour();
		wdate.minute=datetime.time().minute();
		wdate.second=datetime.time().second();

		Query query = m_con.query();
		REMARKT remark(0,mshotno,strwriter,strremark,wdate);
		query.insert(remark);
		query.execute();
	} catch (const mysqlpp::BadQuery& er) {
		cerr << "Query error: " << er.what() << endl;
	} catch (const mysqlpp::Exception& er) {
		cerr << er.what() << endl;
	};
}
开发者ID:Sangil-Lee,项目名称:RefCode,代码行数:29,代码来源:shotresult.cpp

示例9: export_picture

/**
 * Export picture file to disk
 *
 * Demonstrates:
 * - reading the contents of a BLOB
 */
void PhoneBook::export_picture(db_uint id, const char *file_name)
{
    Query q;
    BlobField   blob;

    enum FieldOrder {
        PICTURE_FIELD = 0
    };

    //-------------------------------------------------------------------
    // Select a specific record from the contact table.
    //-------------------------------------------------------------------
    print_error(q.prepare(db, "select picture from contact where id = $<integer>0"), q);
    q.param(0) = id;

    if  (DB_SUCCESS(print_error(q.execute(), q))) {

        blob.attach(q, PICTURE_FIELD);

        //---------------------------------------------------------------
        // Position the cursor to the first record (only 1 record).
        //---------------------------------------------------------------
        if  (q.seek_first() == DB_NOERROR) {
            int             offset, bytes_read;
            db_len_t        blob_size = blob.size();
            const db_len_t  data_size = 256;
            char            data[data_size];

            //-----------------------------------------------------------
            // Open the output file.
            //-----------------------------------------------------------
            FILE *picture_file;
            if ((picture_file = fopen(file_name, "wb")) != NULL) {

                //-------------------------------------------------------
                // Export the BLOB to the output image file
                //-------------------------------------------------------
                for(offset = 0; offset < blob_size; offset += data_size) {
                    if  (bytes_read = blob.read(offset, data, data_size)) {
                        fwrite(data, bytes_read, 1, picture_file);
                    }
                }

                //-------------------------------------------------------
                // Close the output file.
                //-------------------------------------------------------
                fclose(picture_file);

            } else {
                cerr << "Cannot open " << file_name << endl;
            }

        } else {
            cerr << "Could not find contact with id " << (long) id << endl;
        }
    }
    return;
}
开发者ID:ittia,项目名称:phone-book-cpp,代码行数:64,代码来源:phonebook_sql.cpp

示例10: update

	void Editor::update()
	{
		sh::Factory::getInstance().doMonitorShaderFiles();

		if (!mMainWindow)
			return;


		{
			boost::mutex::scoped_lock lock(mSync.mActionMutex);

			// execute pending actions
			while (mMainWindow->mActionQueue.size())
			{
				Action* action = mMainWindow->mActionQueue.front();
				action->execute();
				delete action;
				mMainWindow->mActionQueue.pop();
			}
		}
		{
			boost::mutex::scoped_lock lock(mSync.mQueryMutex);

			// execute pending queries
			for (std::vector<Query*>::iterator it = mMainWindow->mQueries.begin(); it != mMainWindow->mQueries.end(); ++it)
			{
				Query* query = *it;
				if (!query->mDone)
					query->execute();
			}
		}

		boost::mutex::scoped_lock lock2(mSync.mUpdateMutex);

		// update the list of materials
		mMainWindow->mState.mMaterialList.clear();
		sh::Factory::getInstance().listMaterials(mMainWindow->mState.mMaterialList);

		// update global settings
		mMainWindow->mState.mGlobalSettingsMap.clear();
		sh::Factory::getInstance().listGlobalSettings(mMainWindow->mState.mGlobalSettingsMap);

		// update configuration list
		mMainWindow->mState.mConfigurationList.clear();
		sh::Factory::getInstance().listConfigurationNames(mMainWindow->mState.mConfigurationList);

		// update shader list
		mMainWindow->mState.mShaderSets.clear();
		sh::Factory::getInstance().listShaderSets(mMainWindow->mState.mShaderSets);

		mMainWindow->mState.mErrors += sh::Factory::getInstance().getErrorLog();
	}
开发者ID:HaohaoLau,项目名称:stuntrally,代码行数:52,代码来源:Editor.cpp

示例11: LoginUser

// 사용자 로그인 Error나면 Error의 이유를 리턴한다.
int CDBManager::LoginUser(char * szNickname, char * szPassword, int * pRealUserID)
{
	try
	{
		Connection mCon(m_szDBName, m_szIP, m_szUser, m_szPassword);
		Query mQuery = mCon.query();

		// Nickname을 통해 유저의 정보를 얻어 온다.
		mQuery << "SELECT id, nickname, password, online FROM userdata WHERE nickname = \"" << szNickname << "\"";

		Result res = mQuery.store();

		Result::iterator i;
		Row row;
		i = res.begin();

		if(i != res.end())
		{
			row = *i;

			if(!strcmp(szPassword, row["password"]))
			{
				*pRealUserID = row["id"];

				int Online = row["online"];
				if(Online == 1) // 중복 로그인을 막기위해 로그인 필드를 검사한다.
				{
					return MSG_SERV_LOGINBAD_LOGINED;
				}
				// Password가 일치하면 온라인으로 표기 한다.
				mQuery << "UPDATE userdata SET online = 1, lastlogin = NULL WHERE id = " << row["id"];
				mQuery.execute();
			}
			else // Password가 틀렸다.
			{
				return MSG_SERV_LOGINBAD_PASSBAD;
			}
		}
		else // Nickname이 틀렸다.
		{
			return MSG_SERV_LOGINBAD_IDBAD;
		}
	}
	catch(BadQuery er) // DB에러 본래는 쿼리에러다.
	{
		return MSG_SERV_LOGINBAD_DATABASEBAD;
	}

	return -1; // 성공하면 음수를 리턴
}
开发者ID:astromaker,项目名称:sandbox,代码行数:51,代码来源:DBManager.cpp

示例12: update_contact_name

/**
 * Update an existing contact's name.
 *
 * Demonstrates:
 * - searching for existence of a record using an index
 * - edit mode
 */
void PhoneBook::update_contact_name(db_uint id, const wchar_t *newname)
{
    Query q;

    q.prepare(db,
        "update contact "
        "  set name = $<nvarchar>1 "
        "  where id = $<integer>0 ");

    q.param(0) = id;
    q.param(1) = newname;

    print_error(q.execute(), q);
}
开发者ID:ittia,项目名称:phone-book-cpp,代码行数:21,代码来源:phonebook_sql.cpp

示例13: guardar_registro_sensor

bool BaseDeDatos::guardar_registro_sensor(float valor_sensor, int id_sensor_, int tipo_sensor){
  try {
    time_t now = time(0);
    Query query = conn.query();

    switch (tipo_sensor) {
      case 2:{
        registro_temp registro_t(mysqlpp::DateTime(now), valor_sensor, id_sensor_);
        query.insert(registro_t);
      }
      break;

      case 1:{
        registro_humedad registro_h(mysqlpp::DateTime(now), valor_sensor, id_sensor_);
        query.insert(registro_h);
      }
      break;

      case 0:{
        registro_luz registro_l(mysqlpp::DateTime(now), valor_sensor, id_sensor_);
        query.insert(registro_l);
      }
        break;
    }
      // Show the query about to be executed.
      cout << "Query: " << query << endl;
      query.execute();

    }
    catch (const mysqlpp::BadQuery& er) {
        // Handle any query errors
        cerr << "Query error: " << er.what() << endl;
        return false;
    }
    catch (const mysqlpp::BadConversion& er) {
        // Handle bad conversions
        cerr << "Conversion error: " << er.what() << endl <<
                "\tretrieved data size: " << er.retrieved <<
                ", actual size: " << er.actual_size << endl;
        return false;
    }
    catch (const mysqlpp::Exception& er) {
        // Catch-all for any other MySQL++ exceptions
        cerr << "Error: " << er.what() << endl;
        return false;
    }

    return true;

}
开发者ID:rubancar,项目名称:Magic-CPP-Service,代码行数:50,代码来源:BaseDeDatos.cpp

示例14: checkDBFolders

void _ftpEntry::checkDBFolders() {
	bool							isDone						= false;
	Query							serverQuery					= _sqlConnection->query();
	StoreQueryResult				serverResults;
	StoreQueryResult::iterator		storeQueryIT;
	vector<_ftpEntry*>::iterator	entryIT;

	// Nothing to do here...
	if( directorys.empty() )
		return;

	// Get a list of all the directorys that we parent
	serverQuery << "select * from ServerFolders where serverID = " << quote << _serverID;
	serverQuery << " AND parentID = "	<< quote << _folderID;

	// Do the query
	serverResults	= serverQuery.store();

	// None?
	if( !serverResults.size() )
		return;

	// We now have to check each DB result, against the results in directorys vector
	for(storeQueryIT = serverResults.begin(); storeQueryIT != serverResults.end(); storeQueryIT++ , isDone = false) {

		for( entryIT = directorys.begin(); entryIT != directorys.end(); entryIT++) {

			// Does this directory still exist?
			if((*entryIT)->getName() == (string) (*storeQueryIT)["name"]) {
				isDone = true;	// Yes it exists
				break;
			}	// parentID check
		}	// entryIT

		// Deleted?
		if(!isDone) {
			// Yes, remove the entry from the DB

            removeFolderChildren( (size_t) (*storeQueryIT)["folderID"] );
			serverQuery.str("");
			serverQuery << "delete from ServerFolders where folderID = "	<< quote << (*storeQueryIT)["folderID"];

			// bye bye :)
			serverQuery.execute();

		}	// !isDone

	}	// storeQueryIT

}	// checkDBFolders
开发者ID:segrax,项目名称:KiLLARMY,代码行数:50,代码来源:ftpEntry.cpp

示例15: rescanUpdateParent

bool _ftpEntry::rescanUpdateParent(bool value) {
 	Query QueryNewFolder = _sqlConnection->query();

	QueryNewFolder << "UPDATE ServerFolders SET rescanForce = "	<< quote << value;
	QueryNewFolder << " WHERE folderID = "	<< quote << _parentID;

	// go go go
	SimpleResult res = QueryNewFolder.execute();

	if(!res.rows())
		return false;	// No Row changed

	return true;
}
开发者ID:segrax,项目名称:KiLLARMY,代码行数:14,代码来源:ftpEntry.cpp


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