• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ doQuery函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中doQuery函数的典型用法代码示例。如果您正苦于以下问题:C++ doQuery函数的具体用法?C++ doQuery怎么用?C++ doQuery使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: BOOSTER_NOTICE

void dbcontroller::logIP(int teamid) {
    std::stringstream ss;
    ss.str("");
    ss << "teamip_" << teamid;
    teamip ti;
    std::string IP = cur_ctx->request().remote_addr();

    BOOSTER_NOTICE("scoreboard") << "team " << teamid << " has IP " << IP;
    if (cur_ctx->cache().fetch_data(ss.str(), ti)) {
        for (std::vector<std::string>::iterator it = ti.seenip.begin(); it != ti.seenip.end(); ++it) {
            if (IP.compare(*it) == 0) {
                //already known IP for this team
                BOOSTER_DEBUG("scoreboard") << "found in cache.";
                return;
            }
        }
    }

    //Still not known. :(
    std::shared_ptr<QSqlQuery> stmt(new QSqlQuery(this->db));

    bool ok = doQuery(stmt, [&](std::shared_ptr<QSqlQuery> stmt) {
        if (!stmt->prepare("INSERT IGNORE INTO ipteams set idteam=:team, ip=:ip;")) return false;
        stmt->bindValue("team", teamid);
        stmt->bindValue("ip", QString::fromStdString(IP));
        return true;
    });

    if (!ok) {
        BOOSTER_ERROR("scoreboard") << "Could not add IP to teams IPs, aborting";
        return;
    }

    ok = doQuery(stmt, [&](std::shared_ptr<QSqlQuery> stmt) {
        if (!stmt->prepare("SELECT ip FROM ipteams WHERE idteam=:team;")) return false;
        stmt->bindValue("team", teamid);
        return true;
    });

    if (!ok) {
        BOOSTER_ERROR("scoreboard") << "Could not fetch team IP, aborting";
        return;
    }

    if (!ok) return;

    ti.id = teamid;
    ti.seenip.clear();

    while (stmt->next()) {
        ti.seenip.push_back(stmt->record().value(0).toString().toStdString());
        BOOSTER_DEBUG("scoreboard") << "Pushing in cache for team " << teamid << " value " << stmt->record().value(0).toString().toStdString();
    }

    cur_ctx->cache().store_data(ss.str(), ti, -1);
    return;
}
开发者ID:PoliCTF,项目名称:polictf-server,代码行数:57,代码来源:dbcontroller.cpp


示例2: stmt

int dbcontroller::setChallengeSolved(int id) {
    int team = cur_ctx->session().get<int>("teamid");
    std::shared_ptr<QSqlQuery> stmt(new QSqlQuery(this->db));

    bool ok = doQuery(stmt, [&](std::shared_ptr<QSqlQuery> stmt) {
        if (!stmt->prepare("call SolvedChallenge(:team,:idchallenge,@points);")) return false;
        stmt->bindValue("team", team);
        stmt->bindValue("idchallenge", id);
        return true;
    });

    if (!ok) {
        BOOSTER_ERROR("scoreboard") << "SolvedChallenge() failed, aborting";
        return 0;
    }

    stmt->exec("select @points as points from dual;");
    std::stringstream trigger;
    trigger.str("");
    trigger << "teamsolved_" << team;
    cur_ctx->cache().rise(trigger.str());

    if ((stmt->size()) == 1) {
        stmt->next();
        return stmt->record().value("points").toInt();
    } else {
        BOOSTER_ERROR("scoreboard") << "Something went very wrong. SP SolvedChallenge returned " << stmt->size() << " records. Team " << team << " just solved challenge " << id;
        return 0;
    }
}
开发者ID:PoliCTF,项目名称:polictf-server,代码行数:30,代码来源:dbcontroller.cpp


示例3: sqlQuery

teamInfo dbcontroller::fetchTeamInfo(int teamId) {
    std::stringstream cacheKey;
    std::stringstream trigger;
    teamInfo teamInfo;
    cacheKey.str("");
    cacheKey << "teaminfo_" << teamId;
    trigger.str("");
    trigger << "teamsolved_" << teamId;
    std::shared_ptr<QSqlQuery> sqlQuery(new QSqlQuery(this->db));

    bool ok = doQuery(sqlQuery, [&](std::shared_ptr<QSqlQuery> stmt) {
        if (!stmt->prepare("SELECT id, name, points from team where id=:id")) return false;
        stmt->bindValue("id", teamId);
        return true;
    });

    if (!ok) {
        BOOSTER_ERROR("scoreboard") << "Could not fetch info for team, aborting";
        return teamInfo;
    }

    if (sqlQuery->size() != 1) {
        //WTF?
        return teamInfo;
    }

    sqlQuery->next();
    teamInfo.name = sqlQuery->record().value("name").toString().toStdString();
    teamInfo.points = sqlQuery->record().value("points").toUInt();
    cur_ctx->cache().store_data(
        cacheKey.str(), teamInfo, this->makeStringSet(trigger.str()),
        srv->settings().get<int>("cache.timeout.teaminfo")
    );
    return teamInfo;
}
开发者ID:PoliCTF,项目名称:polictf-server,代码行数:35,代码来源:dbcontroller.cpp


示例4: queryOp

        virtual void queryOp( Request& r ){
            QueryMessage q( r.d() );
            
            bool lateAssert = false;
        
            log(3) << "single query: " << q.ns << "  " << q.query << "  ntoreturn: " << q.ntoreturn << endl;
            
            try {
                if ( ( q.ntoreturn == -1 || q.ntoreturn == 1 ) && strstr(q.ns, ".$cmd") ) {
                    BSONObjBuilder builder;
                    bool ok = Command::runAgainstRegistered(q.ns, q.query, builder);
                    if ( ok ) {
                        BSONObj x = builder.done();
                        replyToQuery(0, r.p(), r.m(), x);
                        return;
                    }
                    
                    string commandName = q.query.firstElement().fieldName();
                    if (  ! _commandsSafeToPass.count( commandName ) )
                        log() << "passing through unknown command: " << commandName << " " << q.query << endl;
                }

                lateAssert = true;
                doQuery( r , r.singleServerName() );
            }
            catch ( AssertionException& e ) {
                assert( !lateAssert );
                BSONObjBuilder err;
                err.append("$err", string("mongos: ") + (e.msg.empty() ? "assertion during query" : e.msg));
                BSONObj errObj = err.done();
                replyToQuery(QueryResult::ResultFlag_ErrSet, r.p() , r.m() , errObj);
                return;
            }

        }
开发者ID:whachoe,项目名称:mongo,代码行数:35,代码来源:strategy_single.cpp


示例5: LOGV

status_t FactoryQemuClient::listCameras(char** list)
{
    LOGV("%s", __FUNCTION__);

    QemuQuery query(mQueryList);
    if (doQuery(&query) || !query.isQuerySucceeded()) {
        LOGE("%s: List cameras query failed: %s", __FUNCTION__,
             query.mReplyData ? query.mReplyData : "No error message");
        return query.getCompletionStatus();
    }

    /* Make sure there is a list returned. */
    if (query.mReplyDataSize == 0) {
        LOGE("%s: No camera list is returned.", __FUNCTION__);
        return EINVAL;
    }

    /* Copy the list over. */
    *list = (char*)malloc(query.mReplyDataSize);
    if (*list != NULL) {
        memcpy(*list, query.mReplyData, query.mReplyDataSize);
        LOGD("Emulated camera list: %s", *list);
        return NO_ERROR;
    } else {
        LOGE("%s: Unable to allocate %d bytes",
             __FUNCTION__, query.mReplyDataSize);
        return ENOMEM;
    }
}
开发者ID:26597925,项目名称:mt36k_android_4.0.4,代码行数:29,代码来源:QemuClient.cpp


示例6: doQuery

const char* Format::getField()
{
	doQuery();
	switch(format.fmt.pix.field) {
		case V4L2_FIELD_ANY:
			return "Any";
		case V4L2_FIELD_NONE:
			return "None (progressive or undetermined)";
		case V4L2_FIELD_TOP:
			return "Top";
		case V4L2_FIELD_BOTTOM:
			return "Bottom";
		case V4L2_FIELD_INTERLACED:
			return "Interlaced";
		case V4L2_FIELD_SEQ_TB:
			return "Seq TB";
		case V4L2_FIELD_SEQ_BT:
			return "Seq BT";
		case V4L2_FIELD_ALTERNATE:
			return "Alternate";
		case V4L2_FIELD_INTERLACED_TB:
			return "Interlaced TB";
		case V4L2_FIELD_INTERLACED_BT:
			return "Interlaced BT";
		default:
			return "Unknown field code...\n";
	}
}
开发者ID:spsu,项目名称:image-research,代码行数:28,代码来源:Format.cpp


示例7: doQuery

ResultSet* MySQLPreparedStatement::executeQuery()
{
    //mysql_stmt_store_result(stmt);
    doQuery();

    return new MySQLPreparedResultSet(this, stmt);
}
开发者ID:Anubisss,项目名称:morfeusz,代码行数:7,代码来源:MySQLPreparedStatement.cpp


示例8: sigQueryStatus

void 
KAQuery::slotProcessQueryNow()
{
  /* used to link a timer event to this slot
   * needed for asynchronous query
   */
  if ( !doQuery() && 5==perrno && current_try<=max_retries ) {
    errno2str();
    emit sigQueryStatus( sError );
    current_try++;
    QTimer::singleShot( 300, this, SLOT(slotProcessQueryNow()) );
    return;
  }

  // check the result
  errno2str();
  //sError = p_err_string;
  //  debug( p_err_string );
  nError = perrno;
  //  QString tmp;
  //  debug( (const char*)tmp.setNum(nError) );
  //  sWarning = p_warn_string;
  //  debug( p_warn_string );
  nWarning = pwarn;
  //debug( tmp.setNum(nWarning) );

  emit sigQueryFinished();
  emit sigQueryStatus(i18n("Query finished"));
}
开发者ID:xwizard,项目名称:kde1,代码行数:29,代码来源:KAQuery.cpp


示例9: log

point_count_t RialtoReader::read(PointViewPtr view, point_count_t /*not used*/)
{
    // TODO: okay to ignore point count parameter?
    
    log()->get(LogLevel::Debug) << "RialtoReader::read()" << std::endl;

    const TileMath tmm(m_matrixSet->getTmsetMinX(), m_matrixSet->getTmsetMinY(),
                       m_matrixSet->getTmsetMaxX(), m_matrixSet->getTmsetMaxY(),
                       m_matrixSet->getNumColsAtL0(), m_matrixSet->getNumRowsAtL0());

    setQueryParams();
    
    const double qMinX = m_queryBox.minx;
    const double qMinY = m_queryBox.miny;
    const double qMaxX = m_queryBox.maxx;
    const double qMaxY = m_queryBox.maxy;

    const uint32_t level = m_queryLevel;

    m_gpkg->queryForTiles_begin(m_dataset, qMinX, qMinY, qMaxX, qMaxY, level);

    GpkgTile info;

    do {
        bool ok = m_gpkg->queryForTiles_step(info);
        if (!ok) break;

        doQuery(tmm, info, view, qMinX, qMinY, qMaxX, qMaxY);
        
        log()->get(LogLevel::Debug) << "  resulting view now has "
            << view->size() << " points" << std::endl;
    } while (m_gpkg->queryForTiles_next());

    return view->size();
}
开发者ID:mamayoleksandr,项目名称:rialto-geopackage,代码行数:35,代码来源:RialtoReader.cpp


示例10:

int
DbUtil::createDb(BaseString& m_db)
{
  BaseString stm;
  {
    if(mysql_select_db(m_mysql, m_db.c_str()) == DBU_OK)
    {
      stm.assfmt("DROP DATABASE %s", m_db.c_str());
      if(doQuery(m_db.c_str()) == DBU_FAILED)
        return DBU_FAILED;
    }
    stm.assfmt("CREATE DATABASE %s", m_db.c_str());
    if(doQuery(m_db.c_str()) == DBU_FAILED)
      return DBU_FAILED;
    return DBU_OK;
  }
}
开发者ID:0x00xw,项目名称:mysql-2,代码行数:17,代码来源:DbUtil.cpp


示例11: connect

void ImageViewer::connectWidgets(){
	connect(startBtn, SIGNAL(clicked()), model, SLOT(doRegistration()));
	connect(model, SIGNAL(processingDone()), this, SLOT(enableQuery()));
	connect(queryBtn, SIGNAL(clicked()), model, SLOT(doQuery()));
	connect(model, SIGNAL(queryDone()), this, SLOT(showCorrespondingPoints()));
	connect(matchingBtn, SIGNAL(clicked()), model, SLOT(doMatching()));
	connect(model, SIGNAL(matchingDone()), this, SLOT(showMatchingResult()));

}
开发者ID:projectcs2103t,项目名称:PT,代码行数:9,代码来源:ImageViewer.cpp


示例12: queryOp

        virtual void queryOp( Request& r ) {
            QueryMessage q( r.d() );

            MONGO_LOG(3) << "single query: " << q.ns << "  " << q.query << "  ntoreturn: " << q.ntoreturn << " options : " << q.queryOptions << endl;

            if ( r.isCommand() ) {

                if ( handleSpecialNamespaces( r , q ) )
                    return;

                int loops = 5;
                while ( true ) {
                    BSONObjBuilder builder;
                    try {
                        BSONObj cmdObj = q.query;
                        {
                            BSONElement e = cmdObj.firstElement();
                            if ( e.type() == Object && (e.fieldName()[0] == '$'
                                                         ? str::equals("query", e.fieldName()+1)
                                                         : str::equals("query", e.fieldName())))
                                cmdObj = e.embeddedObject();
                        }
                        bool ok = Command::runAgainstRegistered(q.ns, cmdObj, builder, q.queryOptions);
                        if ( ok ) {
                            BSONObj x = builder.done();
                            replyToQuery(0, r.p(), r.m(), x);
                            return;
                        }
                        break;
                    }
                    catch ( StaleConfigException& e ) {
                        if ( loops <= 0 )
                            throw e;

                        loops--;
                        log() << "retrying command: " << q.query << endl;
                        ShardConnection::checkMyConnectionVersions( e.getns() );
                        if( loops < 4 ) versionManager.forceRemoteCheckShardVersionCB( e.getns() );
                    }
                    catch ( AssertionException& e ) {
                        e.getInfo().append( builder , "assertion" , "assertionCode" );
                        builder.append( "errmsg" , "db assertion failure" );
                        builder.append( "ok" , 0 );
                        BSONObj x = builder.done();
                        replyToQuery(0, r.p(), r.m(), x);
                        return;
                    }
                }

                string commandName = q.query.firstElementFieldName();

                uassert(13390, "unrecognized command: " + commandName, _commandsSafeToPass.count(commandName) != 0);
            }

            doQuery( r , r.primaryShard() );
        }
开发者ID:tanakh,项目名称:mongo,代码行数:56,代码来源:strategy_single.cpp


示例13: doQuery

int MySQLStatement::executeUpdate(const std::string& sql)
{
    doQuery(sql.c_str(), sql.length());
    MYSQL* mysql = mysqlConn->getMySQLHandle();
    if (mysql_field_count(mysql) > 0) { // check if the query return something
        throw MySQLException("MySQLStatement::executeUpdate, error the return something",mysql);
    }

    return static_cast<int>(mysql_affected_rows(mysql));
}
开发者ID:Anubisss,项目名称:morfeusz,代码行数:10,代码来源:MySQLStatement.cpp


示例14: switch

TablaTextAlignCenter* dbHelper::query(int op, QString what, QString where){
    QString queryString;
    switch (op) {
        case 15: queryString = "select * from Visitante, ListaVisitantes where DNI like '"+what+
                "' and Visitante.IDVisitante=ListaVisitantes.IDVisitante and Activo='1' and ListaVisitantes.IDEvento='"+where+
                "';";
                break;
    }
    return doQuery(queryString,op);
}
开发者ID:Venturi,项目名称:proyectodai,代码行数:10,代码来源:dbhelper.cpp


示例15: getCells

//距离查询
void  GlobalMap::doQueryByDistance(LocationDetailPtrList& list,const QueryCase_SpatialRelation& qc){
	MapCellPtrList cells;
	GeoRect rc;
	rc.x = qc.circle.center.lon - qc.circle.radius;
	rc.y = qc.circle.center.lat - qc.circle.radius;
	rc.width = qc.circle.radius * 2;
	rc.height = rc.width;
	cells = getCells(rc);
	doQuery(list,cells,qc);
}
开发者ID:adoggie,项目名称:location_server,代码行数:11,代码来源:map.cpp


示例16: doQuery

VsbRawInfo VsbDevice::getRawInfo()
{
    ByteString data = doQuery(VSB_CMD_GETDEVINFO);
    VsbRawInfo rawInfo = {
        .singlekeyNumKeys = data[0],
        .keyseqNumKeys = data[1],
        .keyseqPageSize = data[2],
        .keyseqNumPages = data[3]
    };
    return rawInfo;
}
开发者ID:gregcourville,项目名称:VerySeriousButton-VerySeriousSetup,代码行数:11,代码来源:vsbprog.cpp


示例17: main

int main(int argc, char **argv){
 // Interpret the command-lin arguments and decide if they make sense
	int status = parseArgs(argc, argv, &prefs);

    printf(COPYRIGHT);
	setLogLevel(LOG_INFO);
	
	if (status == FAIL){
	 // The command-line was duff...
		if (prefs.errorMsg != NULL){
		 // ...and we have a specific error to show the user
			printf("Error: %s\n", prefs.errorMsg);
		} else {
		 // ...and we have no specific error message, so show a vague one
			printf("BitMeter did not understand. ");
		}
		printf("Use the '-h' option to display help.\n");

	} else if (prefs.help){
	 // Dump the help info and stop
		doHelp();

	} else if (prefs.version){
	 // Show the version and stop
		doVersion();

	} else {
	 // We will need to go to the database if we end up here
		openDb();
        dbVersionCheck();

		switch(prefs.mode){
			case PREF_MODE_DUMP:
				doDump();
				break;
			case PREF_MODE_SUMMARY:
				doSummary();
				break;
			case PREF_MODE_MONITOR:
				doMonitor();
				break;
			case PREF_MODE_QUERY:
				doQuery();
				break;
			default:
				assert(FALSE); // Any other mode value should cause parseArgs to fail
				break;
		}

		closeDb();
	}

	return 0;
}
开发者ID:JackWangCUMT,项目名称:bitmeteros,代码行数:54,代码来源:bmclient.c


示例18: doQuery

bool
AtrtClient::getConnectString(int cluster_id, SqlResultSet& result){
  Properties args;
  args.put("0", cluster_id);
  return doQuery("SELECT value as connectstring " \
                 "FROM cluster c, process p, host h, options o "    \
                 "WHERE c.id=p.cluster_id AND p.host_id=h.id AND "  \
                 "p.id=o.process_id AND c.id=? AND "                    \
                 "o.name='--ndb-connectstring=' AND type='ndb_mgmd'",
                 args,
                 result);
}
开发者ID:4T-Shirt,项目名称:mysql,代码行数:12,代码来源:AtrtClient.cpp


示例19: bz_debugMessagef

void leagueOverSeer::URLDone(const char* /*URL*/, const void* data, unsigned int /*size*/, bool /*complete*/) //Everything went fine with the report
{
    std::string siteData = (const char*)(data); //Convert the data to a std::string
    bz_debugMessagef(1, "URL Job Successful! Data returned: %s", siteData.c_str());

    if (strcmp(siteData.substr(0, 6).c_str(), "INSERT") == 0 || strcmp(siteData.substr(0, 6).c_str(), "DELETE") == 0)
        doQuery(siteData);
    else if (strcmp(siteData.c_str(), "<html>") < 0)
    {
        bz_sendTextMessagef(BZ_SERVER, BZ_ALLUSERS, "%s", siteData.c_str());
        bz_debugMessagef(DEBUG, "%s", siteData.c_str());
    }
}
开发者ID:blast007,项目名称:leagueOverSeer,代码行数:13,代码来源:leagueOverSeer.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ doSystem函数代码示例发布时间:2022-05-30
下一篇:
C++ doOpen函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap