本文整理汇总了C++中SelectQuery类的典型用法代码示例。如果您正苦于以下问题:C++ SelectQuery类的具体用法?C++ SelectQuery怎么用?C++ SelectQuery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SelectQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Search
PublicPlaceTableSync::SearchResult PublicPlaceTableSync::Search(
Env& env,
optional<RegistryKeyType> cityId,
optional<string> name,
int first /*= 0*/,
optional<std::size_t> number /*= 0*/,
LinkLevel linkLevel
){
SelectQuery<PublicPlaceTableSync> query;
if(cityId)
{
query.addWhereField(COL_CITYID, *cityId);
}
if(name)
{
query.addWhereField(COL_NAME, *name, ComposedExpression::OP_LIKE);
}
if (number)
query.setNumber(*number + 1);
if (first > 0)
query.setFirst(first);
return LoadFromQuery(query, env, linkLevel);
}
示例2: Search
InterSYNTHESESlaveTableSync::SearchResult InterSYNTHESESlaveTableSync::Search(
Env& env,
std::string name
, int first /*= 0*/,
boost::optional<std::size_t> number
, bool orderByName
, bool raisingOrder,
LinkLevel linkLevel
){
SelectQuery<InterSYNTHESESlaveTableSync> query;
if (!name.empty())
{
query.addWhereField(SimpleObjectFieldDefinition<Name>::FIELD.name, name, ComposedExpression::OP_LIKE);
}
if (orderByName)
{
query.addOrderField(SimpleObjectFieldDefinition<Name>::FIELD.name, raisingOrder);
}
if (number)
{
query.setNumber(*number + 1);
}
if (first > 0)
{
query.setFirst(first);
}
return LoadFromQuery(query, env, linkLevel);
}
示例3: Search
MapSourceTableSync::SearchResult MapSourceTableSync::Search(
util::Env& env,
optional<string> name,
size_t first /*= 0*/,
optional<size_t> number /*= boost::optional<std::size_t>()*/,
bool orderByName,
bool raisingOrder,
util::LinkLevel linkLevel
){
SelectQuery<MapSourceTableSync> query;
if(name)
{
query.addWhereField(COL_NAME, *name, ComposedExpression::OP_LIKE);
}
if(orderByName)
{
query.addOrderField(COL_NAME, raisingOrder);
}
if (number)
{
query.setNumber(*number + 1);
}
if (first > 0)
{
query.setFirst(first);
}
return LoadFromQuery(query, env, linkLevel);
}
示例4: selectObjectQuery
SelectQuery selectObjectQuery(const std::vector<FieldType>& fdatas,
const Expr& e) {
SelectQuery sel;
Split tables;
std::set<LITESQL_String> tableSet;
for (size_t i = 0; i < fdatas.size(); i++)
if (tableSet.find(fdatas[i].table()) == tableSet.end()) {
tables.push_back(fdatas[i].table());
tableSet.insert(fdatas[i].table());
}
Split tableFilters;
tableFilters.resize(tables.size()-1);
for (size_t i = 1; i < tables.size(); i++)
tableFilters[i-1] = tables[i-1] + LITESQL_L(".id_ = ") + tables[i] + LITESQL_L(".id_");
tableSet.clear();
for (size_t i = 0; i < tables.size(); i++) {
sel.source(tables[i]);
tableSet.insert(tables[i]);
}
if (tables.size() > 1)
sel.where((e && RawExpr(tableFilters.join(LITESQL_L(" AND ")))).asString());
else
sel.where(e.asString());
for (size_t i = 0; i < fdatas.size(); i++)
sel.result(fdatas[i].table() + LITESQL_L(".") + fdatas[i].name());
return sel;
}
示例5: LoadFromQuery
DriverAllocationTemplateTableSync::SearchResult DriverAllocationTemplateTableSync::Search(
util::Env& env,
boost::gregorian::date date /*= boost::gregorian::date(not_a_date_time)*/,
size_t first /*= 0*/,
boost::optional<std::size_t> number /*= boost::optional<std::size_t>()*/,
bool orderByDate /*= true*/,
bool raisingOrder /*= true*/,
util::LinkLevel linkLevel /*= util::UP_LINKS_LOAD_LEVEL */
) {
SelectQuery<DriverAllocationTemplateTableSync> query;
if (!date.is_not_a_date())
{
query.addWhereField(SimpleObjectFieldDefinition<Date>::FIELD.name, to_iso_extended_string(date));
}
if (orderByDate)
{
query.addOrderField(SimpleObjectFieldDefinition<Date>::FIELD.name, raisingOrder);
}
if (number)
{
query.setNumber(*number + 1);
}
if (first > 0)
{
query.setFirst(first);
}
return LoadFromQuery(query, env, linkLevel);
}
示例6:
template <> litesql::DataSource<pomotuxdatabase::ActivityInventorySheet> ActivityInAIS::get(const litesql::Database& db, const litesql::Expr& expr, const litesql::Expr& srcExpr)
{
SelectQuery sel;
sel.source(table__);
sel.result(ActivityInventorySheet.fullName());
sel.where(srcExpr);
return DataSource<pomotuxdatabase::ActivityInventorySheet>(db, pomotuxdatabase::ActivityInventorySheet::Id.in(sel) && expr);
}
示例7: loadTypes
void Statistics::loadTypes() {
using namespace Database;
SelectQuery query;
query.addColumn("statistics_types", "stat_type_id");
query.addColumn("statistics_types", "stat_type_name");
query.addServerTable("statistics_types");
auto result = query.execute();
for (const auto &row : result) {
types.emplace(row["stat_type_name"].as<std::string>(), row["stat_type_id"].as<int>());
}
}
示例8: load
void Statistics::load() {
using namespace Database;
SelectQuery query;
query.addColumn("statistics", "stat_type");
query.addColumn("statistics", "stat_players");
query.addColumn("statistics", "stat_bin");
query.addColumn("statistics", "stat_count");
query.addEqualCondition<int>("statistics", "stat_version", versionId);
query.addServerTable("statistics");
auto result = query.execute();
for (const auto &row : result) {
int type = row["stat_type"].as<int>();
int players_online = row["stat_players"].as<int>();
int bin = row["stat_bin"].as<int>();
int count = row["stat_count"].as<int>();
while (statisticsDB[type].size() <= static_cast<size_t>(players_online)) {
statisticsDB[type].emplace_back();
}
statisticsDB[type][players_online][bin] = count;
}
}
示例9: LoadFromQuery
MailingListSubscriptionTableSync::SearchResult MailingListSubscriptionTableSync::Search(
Env& env,
int first /*= 0*/,
optional<size_t> number,
bool raisingOrder,
LinkLevel linkLevel
) {
SelectQuery<MailingListSubscriptionTableSync> query;
if (number)
{
query.setNumber(*number + 1);
}
if (first > 0)
{
query.setFirst(first);
}
return LoadFromQuery(query, env, linkLevel);
}
示例10: Search
RoadChunkTableSync::SearchResult RoadChunkTableSync::Search(
Env& env,
optional<RegistryKeyType> roadId,
int first /*= 0*/,
boost::optional<std::size_t> number /*= 0*/,
LinkLevel linkLevel
){
SelectQuery<RoadChunkTableSync> query;
if(roadId)
{
query.addWhereField(COL_ROADID, *roadId);
}
if (number)
query.setNumber(*number + 1);
if (first > 0)
query.setFirst(first);
return LoadFromQuery(query, env, linkLevel);
}
示例11: Search
TimetableRowTableSync::SearchResult TimetableRowTableSync::Search(
Env& env,
optional<RegistryKeyType> timetableId
, bool orderByTimetable
, bool raisingOrder
, int first
, boost::optional<std::size_t> number,
LinkLevel linkLevel
){
SelectQuery<TimetableRowTableSync> query;
// Selection
if (timetableId)
{
query.addWhereField(COL_TIMETABLE_ID, *timetableId);
}
// Ordering
if (orderByTimetable)
{
query.addOrderField(COL_TIMETABLE_ID, raisingOrder);
query.addOrderField(COL_RANK, raisingOrder);
}
// Size
if (number)
query.setNumber(*number + 1);
if (first > 0)
query.setFirst(first);
return LoadFromQuery(query, env, linkLevel);
}
示例12: Search
TimetableRowGroupItemTableSync::SearchResult TimetableRowGroupItemTableSync::Search(
util::Env& env,
boost::optional<util::RegistryKeyType> timetableRowGroupId,
boost::optional<size_t> rank,
int first,
boost::optional<std::size_t> number,
bool orderByRank,
bool raisingOrder,
util::LinkLevel linkLevel
){
SelectQuery<TimetableRowGroupItemTableSync> query;
if (timetableRowGroupId)
{
query.addWhereField(SimpleObjectFieldDefinition<TimetableRowGroup>::FIELD.name, *timetableRowGroupId);
}
if(rank)
{
query.addWhereField(SimpleObjectFieldDefinition<Rank>::FIELD.name, *rank);
}
if(orderByRank)
{
query.addOrderField(SimpleObjectFieldDefinition<Rank>::FIELD.name, raisingOrder);
}
if (number)
{
query.setNumber(*number + 1);
if (first > 0)
query.setFirst(first);
}
return LoadFromQuery(query, env, linkLevel);
}
示例13: Search
PermanentThreadTableSync::SearchResult PermanentThreadTableSync::Search(
Env& env,
int first /*= 0*/
, optional<size_t> number /*= 0*/
, bool orderByName
, bool raisingOrder,
LinkLevel linkLevel
){
SelectQuery<PermanentThreadTableSync> query;
if (orderByName)
{
query.addOrderField(Name::FIELD.name, raisingOrder);
}
if (number)
{
query.setNumber(*number + 1);
}
if (first > 0)
{
query.setFirst(first);
}
return LoadFromQuery(query, env, linkLevel);
}
示例14: render
std::string MySQLValueRenderer::render(const SelectQuery& x) {
// TODO: Actually, the semantics here may have to be slightly different, because
// a sub-SELECT is allowed to do different things from a toplevel select.
MySQLQueryRenderer renderer{conn, symbolic_relation_resolver};
return wayward::format("({0})", x.to_sql(renderer));
}
示例15: orderBy
/** modifies SelectQuery to order result set
\param f field to order by
\param asc ascending order
\return *this, methods can be chained */
DataSource& orderBy(FieldType f, bool asc=true) {
sel.orderBy(f.fullName(), asc);
return *this;
}