Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions addons/Database/QuerySelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ QuerySelect::QuerySelect(Database& db)
:Query(db)
,select_fields("*")
,where_clause("")
,group_clause("")
,order_clause("")
,limit_clause("")
{
Expand All @@ -16,6 +17,7 @@ QuerySelect::QuerySelect(Database& db, const string& selectFields)
:Query(db)
,select_fields(selectFields)
,where_clause("")
,group_clause("")
,order_clause("")
,limit_clause("")
{
Expand All @@ -37,6 +39,7 @@ QuerySelect& QuerySelect::operator=(const QuerySelect& other) {
from_table = other.from_table;
join_clause = other.join_clause;
where_clause = other.where_clause;
group_clause = other.group_clause;
order_clause = other.order_clause;
limit_clause = other.limit_clause;
field_values = other.field_values;
Expand Down Expand Up @@ -65,6 +68,11 @@ QuerySelect& QuerySelect::order(const string& orderClause) {
order_clause = orderClause;
return *this;
}

QuerySelect& QuerySelect::group(const string& groupClause) {
group_clause = groupClause;
return *this;
}

QuerySelect& QuerySelect::limit(const string& limitClause) {
limit_clause = limitClause;
Expand All @@ -90,6 +98,11 @@ string QuerySelect::toString() {
sql.append(where_clause);
sql.append(" ");
}

if(group_clause.length()) {
sql.append(" group by ");
sql.append(group_clause);
}

if(order_clause.length()) {
sql.append(" order by ");
Expand Down
2 changes: 2 additions & 0 deletions addons/Database/QuerySelect.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class QuerySelect : public Query {

QuerySelect& where(const string& whereClause);
QuerySelect& join(const string& joinClause);
QuerySelect& group(const string& groupClause);
QuerySelect& order(const string& orderClause);


Expand Down Expand Up @@ -78,6 +79,7 @@ class QuerySelect : public Query {
string from_table;
string join_clause;
string where_clause;
string group_clause;
string order_clause;
string limit_clause;

Expand Down