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.

38 lines
1.1 KiB

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