-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
34 lines (31 loc) · 1.06 KB
/
Copy pathmain.cpp
File metadata and controls
34 lines (31 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
// Include generating database files
#include "NewObjectsDB.hpp"
#include "EmployesDb.hpp"
#include "Config.hpp"
#include "etddb/MySqlClient.hpp"
int main() {
Config conf;
EmployesDb emp;
NewObjectsDB obj;
orm::db::Function<int, std::string> count("count");
etd::mysql::Client client(conf.ip, conf.port, conf.login, conf.password);
auto cursor = client.cursor(emp);
std::string request =
orm::query::Select(emp.tEmployees.id,
((orm::db::Column<std::string>) orm::query::Select(count(obj.tObjects.company_id))
.from(obj.tObjects)
.where(obj.tObjects.company_id == emp.tEmployees.company_id)).as("object_count")
).from(emp.tEmployees);
auto result = cursor->executeOne(
request
);
for (auto &[key, rows]: result) {
std::cout << key << ": ";
for (auto &row: rows) {
std::cout << row << ", ";
}
std::cout << std::endl;
}
return 0;
}