datasource.cpp
来自「LiteSQL is a C++ library that integrates」· C++ 代码 · 共 42 行
CPP
42 行
/* LiteSQL - selectObjectQuery - implementation * * By Tero Laitinen * * See LICENSE for copyright information. */#include "compatibility.hpp"#include "litesql/datasource.hpp"namespace litesql {using namespace std;SelectQuery selectObjectQuery(const vector<FieldType>& fdatas, const Expr& e) { SelectQuery sel; Split tables; set<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] + ".id_ = " + tables[i] + ".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(" AND "))).asString()); else sel.where(e.asString()); for (size_t i = 0; i < fdatas.size(); i++) sel.result(fdatas[i].table() + "." + fdatas[i].name()); return sel;}}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?