本文整理汇总了C++中DBQuery::getSeparator方法的典型用法代码示例。如果您正苦于以下问题:C++ DBQuery::getSeparator方法的具体用法?C++ DBQuery::getSeparator怎么用?C++ DBQuery::getSeparator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBQuery
的用法示例。
在下文中一共展示了DBQuery::getSeparator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveBans
bool IOBanSQL::saveBans(const std::string& identifier, const Ban& banclass)
{
Database db;
if(!db.connect(m_db.c_str(), m_host.c_str(), m_user.c_str(), m_pass.c_str())){
return false;
}
DBQuery query;
query << "BEGIN;";
if(!db.executeQuery(query))
return false;
query << "DELETE FROM bans;";
if(!db.executeQuery(query))
return false;
uint32_t currentTime = std::time(NULL);
//save ip bans
bool executeQuery = false;
query.reset();
query << "INSERT INTO `bans` (`type` , `ip` , `mask`, `time`) VALUES ";
for(IpBanList::const_iterator it = banclass.ipBanList.begin(); it != banclass.ipBanList.end(); ++it){
if(it->time > currentTime){
executeQuery = true;
query << query.getSeparator() << "(1," << it->ip << "," << it->mask <<
"," << it->time << ")";
}
}
if(executeQuery){
if(!db.executeQuery(query))
return false;
}
//save player bans
executeQuery = false;
query.reset();
query << "INSERT INTO `bans` (`type` , `player` , `time`) VALUES ";
for(PlayerBanList::const_iterator it = banclass.playerBanList.begin(); it != banclass.playerBanList.end(); ++it){
if(it->time > currentTime){
executeQuery = true;
query << query.getSeparator() << "(2," << it->id << "," << it->time << ")";
}
}
if(executeQuery){
if(!db.executeQuery(query))
return false;
}
//save account bans
executeQuery = false;
query.reset();
query << "INSERT INTO `bans` (`type` , `account` , `time`) VALUES ";
for(AccountBanList::const_iterator it = banclass.accountBanList.begin(); it != banclass.accountBanList.end(); ++it){
if(it->time > currentTime){
executeQuery = true;
query << query.getSeparator() << "(3," << it->id << "," << it->time << ")";
}
}
if(executeQuery){
if(!db.executeQuery(query))
return false;
}
query.reset();
query << "COMMIT;";
if(!db.executeQuery(query))
return false;
return true;
}