You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
963 B

  1. #include "SelectStatementBuilder.h"
  2. namespace db {
  3. namespace statements {
  4. namespace builder {
  5. SelectStatementBuilder &SelectStatementBuilder::columns(const std::string &cols) {
  6. m_statement.body += "SELECT " + cols;
  7. return *this;
  8. }
  9. SelectStatementBuilder &SelectStatementBuilder::from_table(const std::string &table) {
  10. m_statement.body += " FROM " + table + " ";
  11. return *this;
  12. }
  13. SelectStatementBuilder &SelectStatementBuilder::inner_join(const std::string &table, const std::string &on) {
  14. m_statement.body += " INNER JOIN " + table + " ON " + on;
  15. return *this;
  16. }
  17. SelectStatementBuilder &SelectStatementBuilder::where(const std::string &where) {
  18. m_statement.body += " WHERE " + where;
  19. return *this;
  20. }
  21. SelectStatementBuilder &SelectStatementBuilder::close() {
  22. m_statement.body += ";\n";
  23. return *this;
  24. }
  25. }
  26. }
  27. }