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


C++ StoreQueryResult::at方法代码示例

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


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

示例1: getRunning

int getRunning(int id)
{
	int running;
    Connection con(use_exceptions);
    try{
    	ostringstream strbuf;
 	Query query = con.query();
        con.connect(DATABASE, HOST, USER, PASSWORD);
        strbuf << "select running from tasks WHERE id=" << id;
        query << strbuf.str();
        StoreQueryResult res = query.store();
    
        if (res)
        {
            mysqlpp::Row row;
            row = res.at(0);
            running = row["running"];
	    }
    }
    catch (const BadQuery& er)
    {
    // Handle any query errors
        cerr << "getRunning - Query error: " << er.what() << endl;
        return -1;
    }
    catch (const BadConversion& er)
    {
    // Handle bad conversions
        cerr << "getStarted - Conversion error: " << er.what() << endl <<
                "\tretrieved data size: " << er.retrieved <<
                ", actual size: " << er.actual_size << endl;
        return -1;
    }
    catch (const Exception& er)
    {
    // Catch-all for any other MySQL++ exceptions
        cerr << "getRunning - Error: " << er.what() << endl;
        return -1;
    }

    return running;
}        
开发者ID:dxli,项目名称:XR-Fit,代码行数:42,代码来源:nph_mysql.cpp

示例2: getTask

//allocate memory for Task *t before calling the function
void getTask(Task * t, int id)
{
    ostringstream strbuf;
    strbuf << "SELECT * FROM tasks WHERE id=" << id;
    cout<<strbuf.str()<<endl;
    
    Connection con(use_exceptions);
    
    try
    {
        Query query = con.query();
        con.connect(DATABASE, HOST, USER, PASSWORD);
        query << strbuf.str();
        StoreQueryResult res = query.store();
    
        if (res)
        {
            mysqlpp::Row row;
            row = res.at(0);
            t->id = row["id"];
cout<<row["id"]<<endl;
            t->progress = row["progress"];
            t->maxisteps = row["maxisteps"];
            t->date = string(row["date"]);
            t->email = string(row["email"]);
            t->data = string(row["data"]);
	    /*
            t->formula0 = string(row["formula0"]);
            t->formula1 = string(row["formula1"]);
            t->formula12 = string(row["formula12"]);
	    */
            t->started = row["started"];
            t->running = row["running"];
            t->done = row["done"];
            t->error = row["error"];
            t->forward = row["forward"];
            t->fitbulk = row["fitbulk"];
            t->rho0 = row["rho0"];
            t->rho1 = row["rho1"];
            t->rho12 = row["rho12"];
            t->beta0 = row["beta0"];
            t->beta1 = row["beta1"];
            t->beta12 = row["beta12"];
            t->slab = row["slab"];
            t->energy = row["energy"];
            t->qmin = row["qmin"];
            t->qmax = row["qmax"];
            t->nq = row["nq"];
            t->nslab = row["nslab"];
            t->dth = row["dth"];
            t->alpha0 = row["alpha0"];
            t->gamma = row["gamma"];
            t->sigmad = row["sigmad"];
	    /*
            t->rhoin0 = row["rhoin0"];
            t->rhoin1 = row["rhoin1"];
            t->rhoin12 = row["rhoin12"];
	    */
        }
    }
    catch (const BadQuery& er)
    {    
    // Handle any query errors
        cerr << "getTask - Query error: " << er.what() << endl;
    }
    catch (const BadConversion& er)
    {
    // Handle bad conversions
        cerr << "getTask - Conversion error: " << er.what() << endl <<
                "\tretrieved data size: " << er.retrieved <<
                ", actual size: " << er.actual_size << endl;
    }
    catch (const Exception& er)
    {
    // Catch-all for any other MySQL++ exceptions
        cerr << "getTask - Error: " << er.what() << endl;
    }
}
开发者ID:dxli,项目名称:XR-Fit,代码行数:79,代码来源:nph_mysql.cpp

示例3: getNextTaskId

int getNextTaskId()
//searching for a task to start
{
    int id = -1,progress;
    ostringstream strbuf;
    strbuf << "SELECT id,progress FROM tasks WHERE started=0 and running=0 ORDER BY date ASC LIMIT 1";
    
    Connection con(use_exceptions);
    
    try
    {
	Query query = con.query();
	con.connect(DATABASE, HOST, USER, PASSWORD);
	query << strbuf.str();
 StoreQueryResult res = query.store();
	cout<<strbuf.str()<<endl;
	
        if (res && res.num_rows() > 0)
	{
		mysqlpp::Row row;
		row = res.at(0);
		id = row["id"];
		progress = row["progress"];
	}

    }
    catch (const BadQuery& er)
    {    
    // Handle any query errors
        cerr << "getNextTaskId - Query error: " << er.what() << endl;
	    id = -1;
    }
    catch (const BadConversion& er)
    {
    // Handle bad conversions
        cerr << "getNextTaskId - Conversion error: " << er.what() << endl <<
			    "\tretrieved data size: " << er.retrieved <<
			    ", actual size: " << er.actual_size << endl;
	    id = -1;
    }
    catch (const Exception& er)
    {
    // Catch-all for any other MySQL++ exceptions
        cerr << "getNextTaskId - Error: " << er.what() << endl;
	    id = -1;
    }
    if(id>=1 && ! (progress >=1)) { //first time run, convert formula/density
    try{
    	strbuf.str("");
    strbuf << "SELECT energy,formula0,formula1,formula12,rhoin0,rhoin1,rhoin12 FROM tasks WHERE id="<<id;
    	Query query = con.query();
	con.connect(DATABASE, HOST, USER, PASSWORD);
	query << strbuf.str();
 StoreQueryResult res = query.store();
	cout<<strbuf.str()<<endl;
	mysqlpp::Row row;
		row = res.at(0);
		string formula0(row["formula0"]), formula1(row["formula1"]), formula12(row["formula12"]);
		double energy=row["energy"];
		double rhoin0=row["rhoin0"];
		double rhoin1=row["rhoin1"];
		double rhoin12=row["rhoin12"];
		double rho0=0.,rho1=0.,rho12=0.;
		double beta0=0.,beta1=0.,beta12=0.;
		cout<<formula0.size()<<endl;
		cout<<"formula0= "<<formula0<<endl;
		cout<<"formula1= "<<formula1<<endl;
		cout<<"formula12= "<<formula12<<endl;
		cout<<"rhoin0= "<<rhoin0<<endl;
		cout<<"rhoin1= "<<rhoin1<<endl;
		cout<<"rhoin12= "<<rhoin12<<endl;
		compound cmpd0(formula0,energy,rhoin0), cmpd1(formula1,energy,rhoin1), cmpd12(formula12,energy,rhoin12);
		strbuf.str("");
        strbuf << "UPDATE tasks SET rho0="<<cmpd0.rho_el<<",rho1="<<cmpd1.rho_el<<",rho12="<<cmpd12.rho_el<<",beta0="<<cmpd0.beta<<",beta1="<<cmpd1.beta<<",beta12="<<cmpd12.beta<<" WHERE id="<< id;
        //cout<<strbuf.str()<<endl;
        query.exec(strbuf.str());
	cout<<"rho0="<<cmpd0.rho_el<<"\tbeta="<<cmpd0.beta<<endl;
	cout<<"rho1="<<cmpd1.rho_el<<"\tbeta="<<cmpd1.beta<<endl;
	cout<<"rho12(Maximum)="<<cmpd12.rho_el<<"\tbeta="<<cmpd12.beta<<endl;
    }
    
       catch (const BadQuery& er)
    {
    // Handle any query errors
        cerr << "updateDone - Query error: " << er.what() << endl;
        return -1;
    }
    catch (const BadConversion& er)
    {
    // Handle bad conversions
        cerr << "updateDone - Conversion error: " << er.what() << endl <<
                "\tretrieved data size: " << er.retrieved <<
                ", actual size: " << er.actual_size << endl;
        return -1;
    }
    catch (const Exception& er)
    {
    // Catch-all for any other MySQL++ exceptions
        cerr << "updateDone - Error: " << er.what() << endl;
        return -1;
//.........这里部分代码省略.........
开发者ID:dxli,项目名称:XR-Fit,代码行数:101,代码来源:nph_mysql.cpp

示例4: HasNewFile

bool AdUserFeatureCacheI::HasNewFile(){
    stringstream sql;
    sql << " SELECT local_file, md5 FROM user_feature_version "
        << " WHERE id = (SELECT max(id) FROM user_feature_version) "
        << " AND valid = 1 ";

    StoreQueryResult res;
    try{
        const char* DB_HOST = "10.3.23.69";
        const char* DB_NAME = "ad_strategy";
        const char* DB_USER = "ad";
        const char* DB_PASSWORD = "rrad";

	Connection conn(DB_NAME, DB_HOST, DB_USER, DB_PASSWORD);
	Query query(&conn, true, sql.str().c_str());
	res = query.store();
    } catch (Ice::Exception& e){
        MCE_WARN("AdUserFeatureCacheI::HasNewVersion user_feature_version ice error! " << e.what());
        return false;
    } catch (std::exception& e){
        MCE_WARN("AdUserFeatureCacheI::HasNewVersion user_feature_version std error! " << e.what());
        return false;
    }

    if (!res){
        MCE_WARN("Query Result Error!");
        return false;
    }
    else if (res.empty()){
        MCE_INFO("nothing in db!");
        return false;
    }
    else if (res.size() > 1){
	MCE_WARN("There dirty data in user_feature_version.");
	return false;
    }

    string fileName = lexical_cast<string>(res.at(0)["local_file"]);
    string md5Value = lexical_cast<string>(res.at(0)["md5"]);
    //Loading Data of the newFileName now, not finished.
    if (isLoading_){
	MCE_INFO("The File: " << newFileName_ << " is loading.");
	return false;
    }

    /*1). Never Load Data Before. initOK_ == false
     *2). Already there is data in cache, and new file is ready.
     *    newFileName != data's fileName in cache,
     *    and the newFile content md5 != data's content md5 in cache.
     */  
    if ((!initOK_) 
        || ( (fileName != userFeatureDataPtr_->GetFileName())
             && (md5Value != userFeatureDataPtr_->GetMd5Value())
           )
       ){
        IceUtil::RWRecMutex::WLock lock(VERSION_MUTEX);
        {
            newFileName_ = fileName;
            newMd5Value_ = md5Value;;
        }
	return true;
    }
    return false;
}
开发者ID:gunner14,项目名称:old_rr_code,代码行数:64,代码来源:AdUserFeatureCacheI.cpp


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