Added and and or to the query builder, and implemented offset and limit for the sqlite query builder.

This commit is contained in:
Relintai 2021-08-20 13:14:06 +02:00
parent af9979d9a7
commit 4228448fc1
4 changed files with 36 additions and 2 deletions

View File

@ -151,6 +151,13 @@ QueryBuilder *QueryBuilder::offset(const int num) {
return this;
}
QueryBuilder *QueryBuilder::land() {
return this;
}
QueryBuilder *QueryBuilder::lor() {
return this;
}
QueryBuilder *QueryBuilder::w(const std::string &str) {
query_result += str + " ";

View File

@ -64,6 +64,10 @@ public:
virtual QueryBuilder *limit(const int num);
virtual QueryBuilder *offset(const int num);
//l=logical (and, or are operators)
virtual QueryBuilder *land();
virtual QueryBuilder *lor();
virtual QueryBuilder *w(const std::string &str);
virtual QueryBuilder *ew(const std::string &str);

View File

@ -195,13 +195,32 @@ QueryBuilder *SQLite3QueryBuilder::wp(const std::string &col, const bool param)
}
QueryBuilder *SQLite3QueryBuilder::limit(const int num) {
//query_result += "LIMIT " + num + " ";
//todo better way
std::stringstream ss;
ss << num;
query_result += "LIMIT " + ss.str() + " ";
return this;
}
QueryBuilder *SQLite3QueryBuilder::offset(const int num) {
//query_result += "OFFSET " + num + " ";
//todo better way
std::stringstream ss;
ss << num;
query_result += "OFFSET " + ss.str() + " ";
return this;
}
QueryBuilder *SQLite3QueryBuilder::land() {
query_result += "AND ";
return this;
}
QueryBuilder *SQLite3QueryBuilder::lor() {
query_result += "OR ";
return this;
}

View File

@ -50,6 +50,10 @@ public:
QueryBuilder *limit(const int num);
QueryBuilder *offset(const int num);
//l=logical (and, or are operators)
virtual QueryBuilder *land();
virtual QueryBuilder *lor();
QueryBuilder *select_last_insert_id();
std::string escape(const std::string &params);