Added order_by to the QueryBuilder.

This commit is contained in:
Relintai 2021-11-21 16:14:31 +01:00
parent e79ddd1b4a
commit 86b890eb8f
2 changed files with 65 additions and 1 deletions

View File

@ -193,6 +193,58 @@ QueryBuilder *QueryBuilder::offset(const int num) {
return this;
}
QueryBuilder *QueryBuilder::order_by_asc(const String &col) {
query_result += "ORDER BY " + col + " ASC, ";
return this;
}
QueryBuilder *QueryBuilder::order_by_desc(const String &col) {
query_result += "ORDER BY " + col + " DESC, ";
return this;
}
QueryBuilder *QueryBuilder::order_by(const String &col) {
query_result += "ORDER BY " + col + ", ";
return this;
}
QueryBuilder *QueryBuilder::order_by() {
query_result += "ORDER BY ";
return this;
}
QueryBuilder *QueryBuilder::corder_by() {
query_result[query_result.size() - 2] = ' ';
return this;
}
QueryBuilder *QueryBuilder::asc() {
query_result += "ASC, ";
return this;
}
QueryBuilder *QueryBuilder::desc() {
query_result += "DESC, ";
return this;
}
QueryBuilder *QueryBuilder::order_by_add_col(const String &col) {
query_result += col + ", ";
return this;
}
QueryBuilder *QueryBuilder::asc(const String &col) {
query_result += col + " ASC, ";
return this;
}
QueryBuilder *QueryBuilder::desc(const String &col) {
query_result += col + " DESC, ";
return this;
}
QueryBuilder *QueryBuilder::land() {
return this;
}

View File

@ -21,7 +21,7 @@ public:
virtual QueryBuilder *values();
virtual QueryBuilder *cvalues();
virtual QueryBuilder *next_value();
virtual QueryBuilder *begin_transaction();
virtual QueryBuilder *commit();
@ -83,6 +83,18 @@ public:
virtual QueryBuilder *limit(const int num);
virtual QueryBuilder *offset(const int num);
virtual QueryBuilder *order_by_asc(const String &col);
virtual QueryBuilder *order_by_desc(const String &col);
virtual QueryBuilder *order_by(const String &col);
virtual QueryBuilder *order_by();
virtual QueryBuilder *corder_by();
virtual QueryBuilder *asc();
virtual QueryBuilder *desc();
virtual QueryBuilder *order_by_add_col(const String &col);
virtual QueryBuilder *asc(const String &col);
virtual QueryBuilder *desc(const String &col);
//l=logical (and, or are operators)
virtual QueryBuilder *land();
virtual QueryBuilder *lor();