本文整理汇总了C++中StoreQueryResult类的典型用法代码示例。如果您正苦于以下问题:C++ StoreQueryResult类的具体用法?C++ StoreQueryResult怎么用?C++ StoreQueryResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StoreQueryResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: actionMIA
void IRCBot::actionMIA( ircChannel pChannel, irc_reply_data *hostd, string pParameters ) {
size_t count = 1;
size_t lastOnline;
bool active, showAll = false;
if( pParameters == "all" )
showAll = true;
StoreQueryResult members = _db->membersReadSeen( true );
StoreQueryResult::iterator memberIT;
Row member;
for(memberIT = members.begin(); memberIT != members.end(); memberIT++ ) {
stringstream irc;
member = *memberIT;
active = (bool) member["active"];
if( !showAll && !active )
continue;
if( _smokingman->thepipeGet()->userOnline( ((size_t) member["memberID"] ) ) != userOFFLINE )
continue;
lastOnline = (size_t) member["lastOnline"];
irc << count << ". " << ((string) member["nameUser"]) << " : " << timeCalc( time(0) - lastOnline );
speak( "LastOn", irc, pChannel );
++count;
}
}
示例2: 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;
}
示例3: products
/**
@brief Returns the list of products (and requested quantity) of an order
@return A std::map where the key is product ID and the value the quantity
*/
map<int, int>& Order::products()
{
map<int, int> *prd = NULL;
// 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 order_details WHERE oid = "
<< valueForKey(KEY_ORD_OID);
StoreQueryResult res = q.store();
if (!res.empty()) {
prd = new map<int, int>;
StoreQueryResult::const_iterator it;
for (it = res.begin(); it != res.end(); it++){
Row row = *it;
int key = atoi(row["pid"]);
int qty = atoi(row["qty"]);
(*prd)[key] = qty;
}
}
} catch (std::exception &e) {
cerr << "an error occurred: " << e.what() << endl;
}
return *prd;
}
示例4: dbConnect
// 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;
}
示例5: 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();
}
示例6: checkEntryDBFolder
int _ftpEntry::checkEntryDBFolder( ) {
Query serverQuery = _sqlConnection->query();
StoreQueryResult serverResults;
serverQuery << "select * from ServerFolders where serverID = " << quote << _serverID;
serverQuery << " AND parentID = " << quote << _parentID;
serverQuery << " AND name = " << quote << name;
// Do the query
serverResults = serverQuery.store();
// Folder not found?
if( serverResults.size() == 0 )
return 0;
// Root dir?, Number of entrys changed?. time/date diff?, force rescan?
if((timeModified == "" && name == "/") ||
serverResults[0]["entrys"] != entrys ||
serverResults[0]["modTimeDate"] != timeModified ||
(int) serverResults[0]["rescanForce"] == 1 )
return serverResults[0]["folderID"]; // Return the folderID
return -1;
} // checkEntryDBFolder
示例7: run
int
run()
{
c.connect("crowdify", "localhost", "root", "root");
create_test_data();
stringstream qs;
qs.clear();
qs.str(string());
qs << "SELECT * FROM clients;";
Query q = c.query(qs.str());
StoreQueryResult r = q.store();
StoreQueryResult::iterator it;
struct sockaddr_in sin;
char *username, *password;
for (it = r.begin(); it != r.end(); it++) {
Row r = *it;
run_client(r[0]);
}
print_query("select * from blocks;");
print_query("select * from files;");
print_query("select * from clients;");
print_query("select * from filestoblocks;");
print_query("select * from directoriestofiles;");
print_query("select * from clientstodirectories;");
return 0;
}
示例8: 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;
}
示例9: getRow
Row Mysql::getRow(std::string sql){
Query query = _con.query(sql);
Row row;
StoreQueryResult res = query.store();
if (res) {
row = *res.begin();
}
return row;
}
示例10: print_header
static void
print_header(IntVectorType& widths, StoreQueryResult& res)
{
cout << " |" << setfill(' ');
for (size_t i = 0; i < res.field_names()->size(); i++) {
cout << " " << setw(widths.at(i)) << res.field_name(int(i)) << " |";
}
cout << endl;
}
示例11:
int
CScheduler::getProcessNum()
{
Query select = conn->query();
select << "SELECT ProcessQuota FROM crawler WHERE name="
<<quote<<crawler;
StoreQueryResult res = select.store();
if (!res || res.size() == 0)
return -1;
return res[0]["ProcessQuota"];
}
示例12: print_query
int print_query(const char *q) {
Query q2 = c.query(q);
StoreQueryResult r = q2.store();
StoreQueryResult::iterator it;
for (it = r.begin(); it != r.end(); it++) {
Row r = *it;
cout << " " << r[0] << endl;
}
cout << endl;
return 0;
}
示例13: testPrepare
bool IRCBot::testPrepare() {
StoreQueryResult ircBots = _db->ircBotReadAll();
StoreQueryResult::iterator ircIT;
stringstream ircs;
size_t sleepTime = 500, count = 0;
Row irc, ircBot;
_ircMii *botMii;
if(ircBots.empty())
return false;
// loop through and start each server test
for( ircIT = ircBots.begin(); ircIT != ircBots.end(); ++ircIT, ++count ) {
ircBot = *ircIT;
irc = _db->ircRead( (size_t) ircBot["ircID"] );
if(irc.empty())
return false;
botMii = _Miis->ircMiiLoad( (string) irc["nick"] );
if(botMii) {
botMii->ircBotRowLoad();
botMii->silentSet();
botTestAdd( botMii, 0 );
} else {
stringstream ircs;
ircs << "Bot " << ( (string) irc["nick"] ) << " is not online.";
speak("Test", ircs, _testChannel);
}
Sleep(sleepTime);
// Every 4, sleep triple time
if(count == 4) {
Sleep(sleepTime*2);
count=0;
}
}
// Nothing to do?
if(_testMiis.empty()) {
stringstream ircs;
ircs << "No bots to test.";
speak("Test", ircs, _testChannel);
return false;
}
return true;
}
示例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
示例15: checkEntryDBFile
int _ftpEntry::checkEntryDBFile( ) {
Query serverQuery = _sqlConnection->query();
serverQuery << "select * from ServerFiles where folderID = " << quote << _folderID;
serverQuery << " AND name = " << quote << name;
// Fire Scotty!
StoreQueryResult serverResults = serverQuery.store();
// Folder not found?
if( serverResults.size() == 0 )
return 0;
return serverResults[0]["folderID"];
} // checkEntryDBFile