代码拉取完成,页面将自动刷新
#include "src/ccORM.hh"
auto D =
//D_mysql();
//D_pgsql();
D_sqlite("any.db");
#include "module.hh"
//Is the perfect person really the most useless person? I don't know which stupid idiot made the remark.
void test() {
Tab::ptr t = Tab::create(1, true, "日期更变", now(), vector<Type>{ Type{ 1,"typescript" } });
t->Update();//update
t->set(5, false, "更变", now(), vector<Type>{ Type{ 1,"python" }, Type{ 2,"ruby" } }); cout << t << '\n';
*t = json::parse(R"({"id":4,"ok":false,"name":"完美杰作","date":"2021-09-08 01:04:30","types":
[{"id":1,"language":"c++"},{"id":2,"tabs":[{"id":1,"name":"wtf!","ok":1}]},{"id":3,"language":"rust"}]})").get<Tab>();
t->types[1].language = "go programing"; t->types[1].tabs[0].name = "Megatron"; cout << t << '\n';
//cout << "The number with ID " << t->Insert() << " has been inserted\n";//After insertion, a new ID will be returned
//t->Delete();//delete
//Type ty{1, "wwzzgg", 3.1415926}; cout << "The number with ID " << ty.Insert() << " has been inserted\n";
cout << Tab::Q().orderBy(Tab::$date).GetArr(Sort::DESC) << '\n';
vector<Type> vu; vector<Tab> vt = Tab::Q().innerJoin<Type>(Tab::$id==Type::$id).GetArr(&vu); cout << vt << '\n';//one-to-one -> GetArr
*t = Tab::Q().where(Tab::$id == 9).GetOne(); cout << t << '\n';//null
Tab::Q().leftJoin<Type>().GetJson();//leftjoin test
}
int main(int argc, char* argv[]) {
clock_t start = clock(); test(); if constexpr (FastestDev) { return 0; }
Timer t; bool run = true;//Marks the running state of the second thread
t.setTimeout([&run] {
int i = 0; for (; i < 99999; ++i) {
Tab::Q().where(Tab::$id == 2).GetOne();
} printf("<%d>", i);
run = false;//Represents the end of the secondary thread
}, 6);
int i = 0; for (; i < 99998; ++i) {
Tab::Q().where(Tab::$id == 1).GetOne();
}//Multithreading test, here is the first thread, that is, the main thread
printf("<%d>", i);
while (run) { this_thread::yield(); }//If run is true, the program is prevented from ending prematurely
printf("\nuse %.6f seconds", (float)(clock() - start) / CLOCKS_PER_SEC);//Calculate the total time spent
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。