本文整理汇总了C++中StoreQueryResult::num_rows方法的典型用法代码示例。如果您正苦于以下问题:C++ StoreQueryResult::num_rows方法的具体用法?C++ StoreQueryResult::num_rows怎么用?C++ StoreQueryResult::num_rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StoreQueryResult
的用法示例。
在下文中一共展示了StoreQueryResult::num_rows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeStructureFile
int writeStructureFile(int popid, int popnum)
{
int noidis = 0;
int tts=-1;
try
{
ifstream sqlparmfile("../exe/SQLparms.txt");
string servername, dbname, username, password;
getline(sqlparmfile,servername);
getline(sqlparmfile,dbname);
getline(sqlparmfile,username);
getline(sqlparmfile,password);
Connection conn( dbname.c_str(), servername.c_str(), username.c_str(), password.c_str());
Query query = conn.query();
string pp = "pop"+toStrings(popnum);
query << "SELECT "<<pp<<" FROM structure WHERE popstructid = " << popid << " ORDER BY sampleid";
StoreQueryResult ares = query.store();
if(!ares)
{
cerr << query.error() << endl;
return -1;
}
else
{
ofstream myfile;
string fname = "data.test.Z";
myfile.open(fname.c_str());
tts = ares.num_rows();
for(size_t i = 0; i < ares.num_rows(); i ++)
{
myfile << ares[i][pp.c_str()] << "\n";
}
myfile.close();
}
}
catch(BadQuery er)
{
cerr << "Error: " << er.what() << endl;
return -1;
}
catch(const BadConversion& er)
{
cerr << "Conversion error: " << er.what() << endl;
return -1;
}
catch(const Exception& er)
{
cerr << "Error: " << er.what() << endl;
return -1;
}
return tts;
}
示例2: handle_name_exists
static bool handle_name_exists(const StoreQueryResult& result)
{
size_t rowCount = result.num_rows();
assert(rowCount < 2);
return rowCount == 1;
}
示例3: createParmFiles2
void createParmFiles2(string mask, int popid, int popno, int totaltrait, int totalmarker, string db, string name_str)
{
int distinctpop = -1;
try
{
ifstream sqlparmfile("../exe/SQLparms.txt");
string servername, dbname, username, password;
getline(sqlparmfile,servername);
getline(sqlparmfile,dbname);
getline(sqlparmfile,username);
getline(sqlparmfile,password);
Connection conn( dbname.c_str(), servername.c_str(), username.c_str(), password.c_str());
Query query = conn.query();
string pp = "pop"+toStrings(popno);
//SELECT COUNT(DISTINCT pop1 ) as number FROM structure where popstructid = 1;
query << "SELECT COUNT(DISTINCT "<<pp<<" ) as number FROM structure WHERE popstructid = " << popid;
StoreQueryResult ares = query.store();
if(!ares)
{
cerr << query.error() << endl;
return;
}
else
{
for(size_t i = 0; i < ares.num_rows(); i ++)
{
distinctpop = ares[i]["number"] ;
}
}
}
catch(BadQuery er)
{
cerr << "Error: " << er.what() << endl;
return;
}
catch(const BadConversion& er)
{
cerr << "Conversion error: " << er.what() << endl;
return;
}
catch(const Exception& er)
{
cerr << "Error: " << er.what() << endl;
return;
}
ofstream myfile;
myfile.open("parms2.txt");
myfile <<mask<<" "<<popid<<" "<<popno<<" "<<totaltrait<<" "<<totalmarker<<" "<<name_str<<" "<<db<<" "<<distinctpop<< " " << team << endl;
myfile<<"vanilla"<<endl;
myfile.close();
}
示例4: Order
/**
@brief Return the list of all orders of a given user
@param[in] pp An instance of User
@return A vector of Order
*/
vector<Order *> & Order::ordersForUser(User & pp)
{
vector<Order *> *orders = new vector<Order *>;
// get an instance of the database
Database& db = Database::instance();
try {
// ask Database for a valid connection to mySQL
Connection *conn = db.getConnection();
// obtain an instance of mysqlpp::Query and init it
Query q = conn->query();
q << "SELECT * FROM orders WHERE uid = " << pp.uniqueID()
<< " ORDER BY oid, date";
StoreQueryResult res = q.store();
if (!res.empty()) {
orders->reserve(res.num_rows());
StoreQueryResult::const_iterator it;
for (it = res.begin(); it != res.end(); it++){
Row row = *it;
orders->push_back(new Order(row));
}
}
} catch (std::exception &e) {
cerr << "an error occurred: " << e.what() << endl;
}
return *orders;
}
示例5: Category
/**
@brief Returns the list of available categories.
@return Vector of pointer to Category
*/
vector<Category *> &Category::catalog()
{
// get an instance of the database
Database& db = Database::instance();
vector<Category *> *catalog = NULL;
try {
// ask Database for a valid connection to mySQL
Connection *conn = db.getConnection();
// obtain an instance of mysqlpp::Query and init it
Query q = conn->query(SQL_CATEGORY_CAT);
StoreQueryResult res = q.store();
if (!res.empty()) {
catalog = new vector<Category *>;
catalog->reserve(res.num_rows());
for (size_t i = 0; i < res.num_rows(); ++i) {
Category *c = new Category();
c->setValueForKey(KEY_CAT_CID,
(string) res[i][KEY_CAT_CID]);
c->setValueForKey(KEY_CAT_NAME,
(string) res[i][KEY_CAT_NAME]);
catalog->push_back(c);
}
}
}
catch (const mysqlpp::BadQuery& e) {
// Something went wrong with the SQL query.
cerr << "Query failed: " << e.what() << endl;
}
catch (const Exception& er) {
cerr << "Error: " << er.what() << endl;
}
return *catalog;
}
示例6: get_station
int db::get_station(std::string mac) {
StoreQueryResult res = q_get_station.store(mac.c_str(), "");
// found station
if (res.num_rows() > 0) {
mysqlpp::StoreQueryResult::const_iterator it;
mysqlpp::Row row = *(res.begin());
return row[0];
}
cerr << mac << endl;
// new station to db
SimpleResult r_exp = q_insert_station.execute("0", "0", mac.c_str());
return r_exp.insert_id();
}
示例7: ProductProxy
/**
@brief Return the list of products of a given category
@param[in] aCid The category ID
@return A vector of ProductProxy
@note Pass zero as category ID to get all products
*/
vector<ProductProxy *> & ProductProxy::catalog(int aCid)
{
// get an instance of the database
Database& db = Database::instance();
vector<ProductProxy *> *catalog = NULL;
try {
// ask Database for a valid connection to mySQL
Connection *conn = db.getConnection();
// obtain an instance of mysqlpp::Query and init it
Query q = conn->query();
q << SQL_CATALOG_PROXY;
if (aCid != 0)
q << "WHERE cid = " << aCid;
q << " ORDER BY pid, category, name";
StoreQueryResult res = q.store();
if (!res.empty()) {
catalog = new vector<ProductProxy *>;
catalog->reserve(res.num_rows());
for (size_t i = 0; i < res.num_rows(); ++i) {
catalog->push_back(new ProductProxy((int) res[i][0]));
}
}
}
catch (const mysqlpp::BadQuery& e) {
// Something went wrong with the SQL query.
cerr << "Query failed: " << e.what() << endl;
}
catch (const Exception& er) {
cerr << "Error: " << er.what() << endl;
}
return *catalog;
}
示例8: gettsid
int gettsid(string mask)
{
try
{
ifstream sqlparmfile("../exe/SQLparms.txt");
string servername, dbname, username, password;
getline(sqlparmfile,servername);
getline(sqlparmfile,dbname);
getline(sqlparmfile,username);
getline(sqlparmfile,password);
Connection conn( dbname.c_str(), servername.c_str(), username.c_str(), password.c_str());
//cout << conn.error() << endl;
Query query = conn.query();
query << "SELECT get_ts_id('" << mask << "') as id";
StoreQueryResult ares = query.store();
if(!ares)
{
cerr << query.error() << endl;
return -1;
}
int id;
for(size_t i = 0; i < ares.num_rows(); i++)
{
id = ares[i]["id"];
return id;
}
}
catch(BadQuery er)
{
cerr<< "Error: " <<er.what() <<endl;
return -1;
}
catch(const BadConversion& er)
{
cerr <<"Conversion error: " << er.what() << endl;
return -1;
}
catch (const Exception& er)
{
cerr << "Error: " <<er.what() << endl;
return -1;
}
}
示例9: main
int main() {
try {
Connection conn(false);
conn.connect("map", "localhost", "root", "dtbs");
Query query = conn.query();
/* To insert stuff with escaping */
/* query << "INSERT INTO map " <<
"VALUES (" <<
"'', " << // This is left empty because the column is AUTO_INCREMENT
"\"" << escape << "some_var_that_contains_some_value" << "\"" <<
");";
query.execute();*/
/* That's it for INSERT */
/* Now SELECT */
query << "SELECT * FROM Station";
StoreQueryResult ares = query.store();
for (size_t i = 0; i < ares.num_rows(); i++)
cout << "Name: " << ares[i]["id"] << " - Address: " << ares[i]["name"] << endl;
/* Let's get a count of something */
query << "SELECT COUNT(*) FROM Station";
StoreQueryResult bres = query.store();
cout << "Total rows: " << bres[0]["id"];
} catch (BadQuery er) { // handle any connection or
// query errors that may come up
cerr << "Error: " << er.what() << endl;
return -1;
} catch (const BadConversion& er) {
// Handle bad conversions
cerr << "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 << "Error: " << er.what() << endl;
return -1;
}
return (EXIT_SUCCESS);
}
示例10: get_fileinfo
bool MasterServer::get_fileinfo(const string &fid, FileInfo &fileinfo)
{
//查找cache
map<string, FileInfo>::iterator it = m_fileinfo_cache.find(fid);
if(it != m_fileinfo_cache.end())
{
fileinfo = it->second;
return true;
}
//查找数据库
if(m_db_connection == NULL)
return false;
char sql_str[1024];
snprintf(sql_str, 1024, "select fid,name,size,chunkid,chunkip,chunkport,findex,foffset from SFS.fileinfo_%s where fid='%s'"
,fid.substr(0,2).c_str(), fid.c_str());
Query query = m_db_connection->query(sql_str);
StoreQueryResult res = query.store();
if (!res || res.empty())
return false;
size_t i;
for(i=0; i<res.num_rows(); ++i)
{
ChunkPath chunk_path;
fileinfo.fid = res[i]["fid"].c_str();
fileinfo.name = res[i]["name"].c_str();
fileinfo.size = atoi(res[i]["size"].c_str());
chunk_path.id = res[i]["chunkid"].c_str();
chunk_path.ip = res[i]["chunkip"].c_str();
chunk_path.port = atoi(res[i]["chunkport"].c_str());
chunk_path.index = atoi(res[i]["findex"].c_str());
chunk_path.offset = atoi(res[i]["foffset"].c_str());
fileinfo.add_chunkpath(chunk_path);
}
//添加到cache
m_fileinfo_cache.insert(std::make_pair(fileinfo.fid, fileinfo));
return true;
}
示例11: 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;
//.........这里部分代码省略.........
示例12: website_search
const char* WebModelUnified::website_search(const char* req){
JSONObject root;
JSONArray jsarray;
Connection* conn = connect();
Query query = conn->query();
string reqstr(req);
string reqstr_spaced = replaceChar(reqstr, '+', ' ');
vector<string> splittedstr;
split(splittedstr, reqstr_spaced, boost::algorithm::is_any_of(" "));
int titleForce = 10;
int descriptionForce = 1;
int urlForce = 3;
query << "SELECT * , ";
//Occurences total
for(size_t i1 = 0; i1 < splittedstr.size(); i1++)
{
string s = splittedstr[i1];
if(i1 != 0){
query << " + ";
}
query << "((" <<
titleForce << " * (char_length(title) - char_length(replace(title,'" << s << "',''))) + " <<
descriptionForce << " * (char_length(description) - char_length(replace(description,'" << s << "',''))) + " <<
urlForce << " * (char_length(url) - char_length(replace(url,'" << s << "','')))" <<
") / char_length('" << s << "'))";
}
query << " as Occurances " << " FROM website ";
//Where clause
for(size_t i1 = 0; i1 < splittedstr.size(); i1++)
{
string s = splittedstr[i1];
if(i1 == 0) {
query << "WHERE ";
} else {
query << "OR ";
}
query << "(url LIKE '%" << s << "%' or title LIKE '%" << s << "%' or description LIKE '%" << s << "%') ";
}
query << " ORDER BY " << "Occurances desc, title ASC ";
StoreQueryResult ares = query.store();
unsigned int numrow = ares.num_rows();
for(unsigned int i = 0; i < numrow; i++)
{
JSONObject result;
result[L"title"] = new JSONValue(wchartFromChar(ares[i]["title"]));
result[L"description"] = new JSONValue(wchartFromChar(ares[i]["description"]));
result[L"url"] = new JSONValue(wchartFromChar(ares[i]["url"]));
JSONValue* resultVal = new JSONValue(result);
jsarray.push_back(resultVal);
}
root[L"results"] = new JSONValue(jsarray);
JSONValue* jvalue = new JSONValue(root);
const char* returnStr = fromWString(jvalue->Stringify());
delete jvalue;
return returnStr;
}
示例13: insertIntoDB
//.........这里部分代码省略.........
cout<<"file not found: "<<file <<endl;
return;
}
}
string file = "eig_coef";
ifstream myfile(file.c_str());
if(myfile.is_open())
{
for(int i=0; i < totalind; i++)
{
string line;
getline(myfile, line);
vector<string> tokens;
Tokenize(line, tokens,"\t");
cout<<"eigen1 "<<atof(tokens[0].data())<<"\teigen2 "<<atof(tokens[1].data())<<"\teigen3 "<<atof(tokens[2].data())<<endl;
eigen[i][0]=atof(tokens[0].data());
eigen[i][1]=atof(tokens[1].data());
eigen[i][2]=atof(tokens[2].data());
eigen[i][3]=atof(tokens[3].data());
eigen[i][4]=atof(tokens[4].data());
}
}
else
{
cout<<"file not found: "<<file <<endl;
return;
}
//insert
ifstream sqlparmfile("../exe/SQLparms.txt");
string servername, dbname, username, password;
getline(sqlparmfile,servername);
getline(sqlparmfile,dbname);
getline(sqlparmfile,username);
getline(sqlparmfile,password);
Connection conn( dbname.c_str(), servername.c_str(), username.c_str(), password.c_str());
Query query = conn.query();
query << "SELECT createPopStruct(" << msid<< ",'" <<name << "' ) as id";
StoreQueryResult ares = query.store();
int id;
if(!ares)
{
cerr << query.error() << endl;
return;
}
for(size_t i=0; i < ares.num_rows(); i ++)
{
id = ares[i]["id"];
}
//start inserting
query.reset();
for(int i=0; i < totalind; i++)
{
string qstri;
qstri = "INSERT INTO structure (popstructid, sampleid, pop2,pop3,pop4,pop5,pop6,pop7,pop8,pop9,pop10,eig1,eig2,eig3,eig4,eig5) VALUES (";
qstri.append(toStrings(id));
qstri.append(",");
for(int p=0; p<10; p++)
{
qstri.append(toStrings(towrite[i][p]));
qstri.append(",");
}
for(int p=0; p<4; p++)
{
qstri.append(toStrings(eigen[i][p]));
qstri.append(",");
}
qstri.append(toStrings(eigen[i][4]));
qstri.append(")");
cout<<qstri<<endl;
query << qstri;
query.execute();
cout << query.error() << endl;
query.reset();
}
query.reset();
query << "UPDATE popstruct SET loadcmpt = 1 WHERE id = " << id << ";" << endl;
query.execute();
}
catch(BadQuery er)
{
cerr << "Error: " << er.what() << endl;
}
catch(const BadConversion& er)
{
cerr << "Conversion error: " << er.what() << endl;
}
catch(const Exception& er)
{
cerr << "Error: " << er.what() << endl;
}
}
示例14: main
int main(int argc,char **argv)
{
{
char *ee = getenv("ZT_NETCONF_MYSQL_HOST");
if (!ee) {
fprintf(stderr,"missing environment variable: ZT_NETCONF_MYSQL_HOST\n");
return -1;
}
strcpy(mysqlHost,ee);
ee = getenv("ZT_NETCONF_MYSQL_PORT");
if (!ee)
strcpy(mysqlPort,"3306");
else strcpy(mysqlPort,ee);
ee = getenv("ZT_NETCONF_MYSQL_DATABASE");
if (!ee) {
fprintf(stderr,"missing environment variable: ZT_NETCONF_MYSQL_DATABASE\n");
return -1;
}
strcpy(mysqlDatabase,ee);
ee = getenv("ZT_NETCONF_MYSQL_USER");
if (!ee) {
fprintf(stderr,"missing environment variable: ZT_NETCONF_MYSQL_USER\n");
return -1;
}
strcpy(mysqlUser,ee);
ee = getenv("ZT_NETCONF_MYSQL_PASSWORD");
if (!ee) {
fprintf(stderr,"missing environment variable: ZT_NETCONF_MYSQL_PASSWORD\n");
return -1;
}
strcpy(mysqlPassword,ee);
}
char buf[131072],buf2[131072];
Identity signingIdentity;
std::string dictBuf;
try {
dbCon = new Connection(mysqlDatabase,mysqlHost,mysqlUser,mysqlPassword,(unsigned int)strtol(mysqlPort,(char **)0,10));
if (dbCon->connected()) {
fprintf(stderr,"connected to mysql server successfully\n");
} else {
fprintf(stderr,"unable to connect to database server\n");
return -1;
}
} catch (std::exception &exc) {
fprintf(stderr,"unable to connect to database server: %s\n",exc.what());
return -1;
}
// Send ready message to tell parent that the service is up, and to
// solicit netconf-init.
{
Dictionary response;
response["type"] = "ready";
std::string respm = response.toString();
uint32_t respml = (uint32_t)htonl((uint32_t)respm.length());
stdoutWriteLock.lock();
write(STDOUT_FILENO,&respml,4);
write(STDOUT_FILENO,respm.data(),respm.length());
stdoutWriteLock.unlock();
}
for(;;) {
for(int l=0;l<4;) {
int n = (int)read(STDIN_FILENO,buf + l,4 - l);
if (n < 0) {
fprintf(stderr,"error reading frame size from stdin: %s\n",strerror(errno));
return -1;
}
l += n;
}
unsigned int fsize = (unsigned int)ntohl(*((const uint32_t *)buf));
while (dictBuf.length() < fsize) {
int n = (int)read(STDIN_FILENO,buf,std::min((int)sizeof(buf),(int)(fsize - dictBuf.length())));
if (n < 0) {
fprintf(stderr,"error reading frame from stdin: %s\n",strerror(errno));
return -1;
}
for(int i=0;i<n;++i)
dictBuf.push_back(buf[i]);
}
Dictionary request(dictBuf);
dictBuf = "";
if (!dbCon->connected()) {
fprintf(stderr,"connection to database server lost\n");
return -1;
}
// Check QNetworkConfigRefresh (MEMORY table) and push network
// config refreshes to queued peer/network pairs.
try {
Dictionary to;
{
Query q = dbCon->query();
q << "SELECT DISTINCT LOWER(HEX(Node_id)) AS Node_id,LOWER(HEX(Network_id)) AS Network_id FROM QNetworkConfigRefresh";
StoreQueryResult rs = q.store();
for(unsigned long i=0;i<rs.num_rows();++i) {
//.........这里部分代码省略.........
示例15: writeMarkerFile
int writeMarkerFile(string mask, string filename)
{
int noidis = 0;
try
{
ifstream sqlparmfile("../exe/SQLparms.txt");
string servername, dbname, username, password;
getline(sqlparmfile,servername);
getline(sqlparmfile,dbname);
getline(sqlparmfile,username);
getline(sqlparmfile,password);
Connection conn( dbname.c_str(), servername.c_str(), username.c_str(), password.c_str());
Query query = conn.query();
query << "Select get_ms_id('"<<mask<<"') as id";
StoreQueryResult ares = query.store();
int id;
if(!ares)
{
cerr<<query.error()<<endl;
return -1;
}
for(size_t i = 0; i<ares.num_rows(); i++)
{
id = ares[i]["id"];
//cout << id << endl;
}
query.reset();
//cout << "ID" << id << endl;
query << "SELECT id FROM marker WHERE markersetid= " << id << " ORDER BY idx";
//cout << query.str() << endl;
ares = query.store();
if(!ares)
{
cerr << "Right here. " << endl;
cerr << query.error()<<endl;
return -1;
}
else
{
//run here query once to get size of samples and than store it in a 2d int array
Query q3 = conn.query();
q3 << "SELECT value FROM markerval" << team << ", marker WHERE markerid = marker.id AND markerid = " << ares [0]["id"] << " ORDER BY idx";
StoreQueryResult ares3 = q3.store();
int totalind= ares3.num_rows();
int totalmark = ares.num_rows();
q3.reset();
double towrite[totalind][totalmark];
ofstream myfile;
myfile.open(filename.c_str());
ofstream myfile11;
string fn = "data.vocab";
myfile11.open(fn.c_str());
noidis = ares.num_rows();
for (size_t i = 0; i <ares.num_rows(); i++)
{
myfile11 << ares[i]["id"] << "\n";
Query q2 = conn.query();
q2 << "SELECT value FROM markerval" << team << ", marker WHERE markerid = marker.id AND markerid = " << ares [i]["id"] << " ORDER BY idx";
//cout << q2.str() << endl;
StoreQueryResult ares2 = q2.store();
// noidis = ares2.num_rows();
//cout << noidis << endl;
for(size_t j = 0; j <ares2.num_rows(); j ++)
{
towrite[j][i] = (double)ares2[j]["value"] ;
//myfile << ares2[j]["value"] << "\t";
}
//myfile << endl;
q2.reset();
}
myfile11.close();
for(int ind=0; ind <totalind ; ind++ )
{
for(int mark=0; mark<totalmark; mark++)
{
myfile << towrite[ind][mark] << "\t";
}
myfile << endl;
}
myfile.close();
}
}
catch(BadQuery er)
{
cerr << "Error: " << er.what() << endl;
return -1;
}
//.........这里部分代码省略.........