本文整理汇总了C++中SQLStatement::SetStatementType方法的典型用法代码示例。如果您正苦于以下问题:C++ SQLStatement::SetStatementType方法的具体用法?C++ SQLStatement::SetStatementType怎么用?C++ SQLStatement::SetStatementType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLStatement
的用法示例。
在下文中一共展示了SQLStatement::SetStatementType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool
PersistentFetchAccount::SaveObject(shared_ptr<FetchAccount> pFA)
{
SQLStatement oStatement;
oStatement.SetTable("hm_fetchaccounts");
bool bNewObject = pFA->GetID() == 0;
oStatement.AddColumnInt64("faaccountid", pFA->GetAccountID());
oStatement.AddColumn("faactive", pFA->GetActive() ? 1 : 0);
oStatement.AddColumn("faaccountname", pFA->GetName());
oStatement.AddColumn("faserveraddress", pFA->GetServerAddress());
oStatement.AddColumn("faserverport", pFA->GetPort());
oStatement.AddColumn("faservertype", pFA->GetServerType());
oStatement.AddColumn("fausername", pFA->GetUsername());
oStatement.AddColumn("fapassword", Crypt::Instance()->EnCrypt(pFA->GetPassword(), Crypt::ETBlowFish));
oStatement.AddColumn("faminutes", pFA->GetMinutesBetweenTry());
oStatement.AddColumn("fadaystokeep", pFA->GetDaysToKeep());
oStatement.AddColumn("fanexttry", Time::GetCurrentDateTime());
oStatement.AddColumn("faprocessmimerecipients", pFA->GetProcessMIMERecipients());
oStatement.AddColumn("faprocessmimedate", pFA->GetProcessMIMEDate());
oStatement.AddColumn("fausessl", pFA->GetUseSSL());
oStatement.AddColumn("fauseantispam", pFA->GetUseAntiSpam());
oStatement.AddColumn("fauseantivirus", pFA->GetUseAntiVirus());
oStatement.AddColumn("faenablerouterecipients", pFA->GetEnableRouteRecipients());
if (bNewObject)
{
oStatement.SetStatementType(SQLStatement::STInsert);
oStatement.SetIdentityColumn("faid");
oStatement.AddColumn("falocked", 0);
}
else
{
String sWhere;
sWhere.Format(_T("faid = %I64d"), pFA->GetID());
oStatement.SetStatementType(SQLStatement::STUpdate);
oStatement.SetWhereClause(sWhere);
}
// Save and fetch ID
__int64 iDBID = 0;
bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0);
if (bRetVal && bNewObject)
pFA->SetID((int) iDBID);
return bRetVal;
}
示例2:
bool
PersistentRoute::SaveObject(std::shared_ptr<Route> pRoute, String &sErrorMessage, PersistenceMode mode)
{
if (!PreSaveLimitationsCheck::CheckLimitations(mode, pRoute, sErrorMessage))
return false;
SQLStatement oStatement;
oStatement.SetTable("hm_routes");
oStatement.AddColumn("routedomainname", pRoute->DomainName());
oStatement.AddColumn("routedescription", pRoute->GetDescription());
oStatement.AddColumn("routetargetsmthost", pRoute->TargetSMTPHost());
oStatement.AddColumn("routetargetsmtport", pRoute->TargetSMTPPort());
oStatement.AddColumn("routenooftries", pRoute->NumberOfTries());
oStatement.AddColumn("routeminutesbetweentry", pRoute->MinutesBetweenTry());
oStatement.AddColumn("routealladdresses", pRoute->ToAllAddresses() ? 1 : 0);
oStatement.AddColumn("routeuseauthentication", pRoute->GetRelayerRequiresAuth() ? 1 : 0);
oStatement.AddColumn("routeauthenticationusername", pRoute->GetRelayerAuthUsername());
oStatement.AddColumn("routeauthenticationpassword", Crypt::Instance()->EnCrypt(pRoute->GetRelayerAuthPassword(), Crypt::ETBlowFish));
oStatement.AddColumn("routetreatsecurityaslocal", pRoute->GetTreatRecipientAsLocalDomain() ? 1 : 0);
oStatement.AddColumn("routetreatsenderaslocaldomain", pRoute->GetTreatSenderAsLocalDomain() ? 1 : 0);
oStatement.AddColumn("routeconnectionsecurity", pRoute->GetConnectionSecurity() );
if (pRoute->GetID() == 0)
{
oStatement.SetStatementType(SQLStatement::STInsert);
oStatement.SetIdentityColumn("routeid");
}
else
{
oStatement.SetStatementType(SQLStatement::STUpdate);
String sWhere;
sWhere.Format(_T("routeid = %I64d"), pRoute->GetID());
oStatement.SetWhereClause(sWhere);
}
bool bNewObject = pRoute->GetID() == 0;
// Save and fetch ID
__int64 iDBID = 0;
bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0);
if (bRetVal && bNewObject)
pRoute->SetID((int) iDBID);
return true;
}
示例3:
bool
PersistentIMAPFolder::SaveObject(std::shared_ptr<IMAPFolder> pFolder)
{
bool bNewObject = true;
if (pFolder->GetID())
bNewObject = false;
SQLStatement oStatement;
oStatement.SetTable("hm_imapfolders");
if (bNewObject)
{
oStatement.SetStatementType(SQLStatement::STInsert);
oStatement.SetIdentityColumn("folderid");
DateTime creationTime = pFolder->GetCreationTime();
if (pFolder->GetCreationTime().GetStatus() == DateTime::invalid)
pFolder->SetCreationTime(DateTime::GetCurrentTime());
// This column is always updated by GetUniqueMessageID below
// but we still need to create it.
oStatement.AddColumn("foldercurrentuid", pFolder->GetCurrentUID());
oStatement.AddColumnDate("foldercreationtime", pFolder->GetCreationTime());
}
else
{
oStatement.SetStatementType(SQLStatement::STUpdate);
String sWhere;
sWhere.Format(_T("folderid = %I64d"), pFolder->GetID());
oStatement.SetWhereClause(sWhere);
}
oStatement.AddColumnInt64("folderaccountid", pFolder->GetAccountID());
oStatement.AddColumnInt64("folderparentid", pFolder->GetParentFolderID());
oStatement.AddColumn("foldername", pFolder->GetFolderName());
oStatement.AddColumn("folderissubscribed", pFolder->GetIsSubscribed() ? 1 : 0);
__int64 iDBID = 0;
bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0);
if (bRetVal && bNewObject)
pFolder->SetID((int) iDBID);
return true;
}
示例4:
bool
PersistentSecurityRange::Exists(const String &name)
{
String whereClause = "rangename = '" + SQLStatement::Escape(name) + "'";
SQLStatement oStatement;
oStatement.SetStatementType(SQLStatement::STSelect);
oStatement.SetTable("hm_securityranges");
oStatement.AddColumn("count(*) as c");
oStatement.SetWhereClause(whereClause);
shared_ptr<DALRecordset> pRS = Application::Instance()->GetDBManager()->OpenRecordset(oStatement);
if (!pRS)
return false;
bool bRetVal = false;
if (!pRS->IsEOF())
{
int count = pRS->GetLongValue("c");
if (count > 0)
return true;
}
return false;
}
示例5:
bool
PersistentGreyList::AddObject(shared_ptr<GreyListTriplet> pTriplet)
//---------------------------------------------------------------------------()
// DESCRIPTION:
// Adds a new greylist triple into the database.
//---------------------------------------------------------------------------()
{
String sSenderAddress = pTriplet->GetSenderAddress().Left(200);
String sRecipientAddress = pTriplet->GetRecipientAddress().Left(200);
// Update the triplet
SQLStatement oStatement;
IPAddressSQLHelper helper;
oStatement.SetTable("hm_greylisting_triplets");
oStatement.AddColumn("glcreatetime", pTriplet->GetCreateTime());
oStatement.AddColumn("glblockendtime", pTriplet->GetBlockEndTime());
oStatement.AddColumn("gldeletetime", pTriplet->GetDeleteTime());
helper.AppendStatement(oStatement, pTriplet->GetIPAddress(), "glipaddress1", "glipaddress2");
oStatement.AddColumn("glsenderaddress", sSenderAddress);
oStatement.AddColumn("glrecipientaddress", sRecipientAddress);
oStatement.AddColumn("glpassedcount", "0");
oStatement.AddColumn("glblockedcount", "0");
oStatement.SetStatementType(SQLStatement::STInsert);
oStatement.SetIdentityColumn("glid");
bool bResult = Application::Instance()->GetDBManager()->Execute(oStatement, 0, DALConnection::DALErrorInSQL);
return bResult;
}
示例6: Instance
/*
Delete metadata info for messages no longer in the system.
*/
bool
PersistentMessageMetaData::DeleteOrphanedItems()
{
SQLStatement statement;
statement.SetTable("hm_message_metadata");
statement.SetStatementType(SQLStatement::STDelete);
statement.SetWhereClause("not exists (select messageid from hm_messages where messageid = metadata_messageid)");;
return Application::Instance()->GetDBManager()->Execute(statement);
}
示例7:
bool
PersistentTCPIPPort::SaveObject(boost::shared_ptr<TCPIPPort> pObject)
{
SQLStatement oStatement;
oStatement.SetTable("hm_tcpipports");
if (pObject->GetID() == 0)
{
oStatement.SetStatementType(SQLStatement::STInsert);
oStatement.SetIdentityColumn("portid");
}
else
{
oStatement.SetStatementType(SQLStatement::STUpdate);
String sWhere;
sWhere.Format(_T("portid = %I64d"), pObject->GetID());
oStatement.SetWhereClause(sWhere);
}
__int64 iAddress = 0;
IPAddressSQLHelper helper;
oStatement.AddColumn("portprotocol", pObject->GetProtocol());
oStatement.AddColumn("portnumber", pObject->GetPortNumber());
oStatement.AddColumnInt64("portsslcertificateid", pObject->GetSSLCertificateID());
helper.AppendStatement(oStatement, pObject->GetAddress(), "portaddress1", "portaddress2");
oStatement.AddColumn("portusessl", pObject->GetUseSSL());
bool bNewObject = pObject->GetID() == 0;
// Save and fetch ID
__int64 iDBID = 0;
bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0);
if (bRetVal && bNewObject)
pObject->SetID((int) iDBID);
return true;
}
示例8:
bool
PersistentDistributionList::SaveObject(std::shared_ptr<DistributionList> pDistList, String &sErrorMessage, PersistenceMode mode)
{
if (!PreSaveLimitationsCheck::CheckLimitations(mode, pDistList, sErrorMessage))
return false;
SQLStatement oStatement;
oStatement.SetTable("hm_distributionlists");
oStatement.AddColumnInt64("distributionlistdomainid", pDistList->GetDomainID());
oStatement.AddColumn("distributionlistenabled", pDistList->GetActive() ? 1 : 0);
oStatement.AddColumn("distributionlistaddress", pDistList->GetAddress());
oStatement.AddColumn("distributionlistrequireauth", pDistList->GetRequireAuth() ? 1 : 0);
oStatement.AddColumn("distributionlistrequireaddress", pDistList->GetRequireAddress());
oStatement.AddColumn("distributionlistmode", pDistList->GetListMode());
if (pDistList->GetID() == 0)
{
oStatement.SetStatementType(SQLStatement::STInsert);
oStatement.SetIdentityColumn("distributionlistid");
}
else
{
oStatement.SetStatementType(SQLStatement::STUpdate);
String sWhere;
sWhere.Format(_T("distributionlistid = %I64d"), pDistList->GetID());
oStatement.SetWhereClause(sWhere);
}
bool bNewObject = pDistList->GetID() == 0;
// Save and fetch ID
__int64 iDBID = 0;
bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0);
if (bRetVal && bNewObject)
pDistList->SetID((int) iDBID);
Cache<DistributionList>::Instance()->RemoveObject(pDistList);
return bRetVal;
}
示例9: ReadObject
bool
PersistentDistributionList::ReadObject(std::shared_ptr<DistributionList> pDistList, const String &sAddress)
{
SQLStatement statement;
statement.SetStatementType(SQLStatement::STSelect);
statement.SetTable("hm_distributionlists");
statement.AddWhereClauseColumn("distributionlistaddress", sAddress);
return ReadObject(pDistList, statement.GetCommand());
}
示例10: ReadObject
bool
PersistentAlias::ReadObject(std::shared_ptr<Alias> pAlias, const String & sName)
{
SQLStatement statement;
statement.SetStatementType(SQLStatement::STSelect);
statement.SetTable("hm_aliases");
statement.AddWhereClauseColumn("aliasname", sName);
return ReadObject(pAlias, statement.GetCommand());
}
示例11:
bool
PersistentAlias::SaveObject(std::shared_ptr<Alias> pAlias, String &sErrorMessage, PersistenceMode mode)
{
if (!PreSaveLimitationsCheck::CheckLimitations(mode, pAlias, sErrorMessage))
return false;
SQLStatement oStatement;
oStatement.SetTable("hm_aliases");
oStatement.AddColumnInt64("aliasdomainid", pAlias->GetDomainID());
oStatement.AddColumn("aliasname", pAlias->GetName());
oStatement.AddColumn("aliasvalue", pAlias->GetValue());
oStatement.AddColumn("aliasactive", pAlias->GetIsActive());
if (pAlias->GetID() == 0)
{
oStatement.SetStatementType(SQLStatement::STInsert);
oStatement.SetIdentityColumn("aliasid");
}
else
{
oStatement.SetStatementType(SQLStatement::STUpdate);
String sWhere;
sWhere.Format(_T("aliasid = %I64d"), pAlias->GetID());
oStatement.SetWhereClause(sWhere);
}
bool bNewObject = pAlias->GetID() == 0;
// Save and fetch ID
__int64 iDBID = 0;
bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0);
if (bRetVal && bNewObject)
pAlias->SetID((int) iDBID);
Cache<Alias>::Instance()->RemoveObject(pAlias);
return bRetVal;
}
示例12:
bool
PersistentGroupMember::SaveObject(shared_ptr<GroupMember> pObject)
{
SQLStatement oStatement;
oStatement.AddColumnInt64("membergroupid", pObject->GetGroupID());
oStatement.AddColumnInt64("memberaccountid", pObject->GetAccountID());
oStatement.SetTable("hm_group_members");
if (pObject->GetID() == 0)
{
oStatement.SetStatementType(SQLStatement::STInsert);
oStatement.SetIdentityColumn("memberid");
}
else
{
oStatement.SetStatementType(SQLStatement::STUpdate);
String sWhere;
sWhere.Format(_T("memberid = %I64d"), pObject->GetID());
oStatement.SetWhereClause(sWhere);
}
bool bNewObject = pObject->GetID() == 0;
// Save and fetch ID
__int64 iDBID = 0;
bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0);
if (bRetVal && bNewObject)
pObject->SetID((long) iDBID);
Cache<Group, PersistentGroup>::Instance()->RemoveObject(pObject->GetGroupID());
return bRetVal;
}
示例13:
bool
PersistentRuleCriteria::SaveObject(std::shared_ptr<RuleCriteria> pRuleCriteria)
{
SQLStatement oStatement;
oStatement.SetTable("hm_rule_criterias");
bool bNewObject = pRuleCriteria->GetID() == 0;
if (bNewObject)
{
oStatement.SetStatementType(SQLStatement::STInsert);
oStatement.SetIdentityColumn("criteriaid");
}
else
{
oStatement.SetStatementType(SQLStatement::STUpdate);
String sWhere;
sWhere.Format(_T("criteriaid = %I64d"), pRuleCriteria->GetID());
oStatement.SetWhereClause(sWhere);
}
oStatement.AddColumnInt64("criteriaruleid", pRuleCriteria->GetRuleID());
oStatement.AddColumn("criteriausepredefined", pRuleCriteria->GetUsePredefined());
oStatement.AddColumn("criteriapredefinedfield", pRuleCriteria->GetPredefinedField());
oStatement.AddColumn("criteriaheadername", pRuleCriteria->GetHeaderField());
oStatement.AddColumn("criteriamatchtype", pRuleCriteria->GetMatchType());
oStatement.AddColumn("criteriamatchvalue", pRuleCriteria->GetMatchValue());
// Save and fetch ID
__int64 iDBID = 0;
bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0);
if (bRetVal && bNewObject)
pRuleCriteria->SetID((int) iDBID);
return bRetVal;
}
示例14: ReadObject
bool
PersistentAccount::ReadObject(boost::shared_ptr<Account> pAccount, const String & sAddress)
{
SQLStatement statement;
statement.SetStatementType(SQLStatement::STSelect);
statement.SetTable("hm_accounts");
statement.AddWhereClauseColumn("accountaddress", sAddress);
bool bResult = ReadObject(pAccount, statement.GetCommand());
return bResult;
}
示例15:
bool
PersistentDomainAlias::SaveObject(shared_ptr<DomainAlias> oDA, String &sErrorMessage)
{
if (!PreSaveLimitationsCheck::CheckLimitations(oDA, sErrorMessage))
return false;
SQLStatement oStatement;
oStatement.SetTable("hm_domain_aliases");
bool bNewObject = oDA->GetID() == 0;
oStatement.AddColumnInt64("dadomainid", oDA->GetDomainID());
oStatement.AddColumn("daalias", oDA->GetAlias());
if (bNewObject)
{
oStatement.SetStatementType(SQLStatement::STInsert);
oStatement.SetIdentityColumn("daid");
}
else
{
String sWhere;
sWhere.Format(_T("daid = %I64d"), oDA->GetID());
oStatement.SetStatementType(SQLStatement::STUpdate);
oStatement.SetWhereClause(sWhere);
}
// Save and fetch ID
__int64 iDBID = 0;
bool bRetVal = Application::Instance()->GetDBManager()->Execute(oStatement, bNewObject ? &iDBID : 0);
if (bRetVal && bNewObject)
oDA->SetID((int) iDBID);
ObjectCache::Instance()->SetDomainAliasesNeedsReload();
return true;
}