2020-12-01 21:48:13 +01:00
|
|
|
#ifndef QUERY_BUILDER_H
|
|
|
|
#define QUERY_BUILDER_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2021-08-19 14:12:02 +02:00
|
|
|
class QueryResult;
|
|
|
|
|
|
|
|
//methods that start with an e escape their params.
|
|
|
|
|
2020-12-01 21:48:13 +01:00
|
|
|
class QueryBuilder {
|
|
|
|
public:
|
2021-08-19 14:12:02 +02:00
|
|
|
virtual QueryBuilder *select();
|
|
|
|
virtual QueryBuilder *where();
|
|
|
|
virtual QueryBuilder *from();
|
|
|
|
virtual QueryBuilder *insert();
|
|
|
|
virtual QueryBuilder *values();
|
|
|
|
virtual QueryBuilder *cvalues();
|
|
|
|
|
2020-12-01 21:48:13 +01:00
|
|
|
virtual QueryBuilder *select(const std::string ¶ms);
|
|
|
|
virtual QueryBuilder *where(const std::string ¶ms);
|
|
|
|
virtual QueryBuilder *from(const std::string ¶ms);
|
2021-08-19 14:12:02 +02:00
|
|
|
virtual QueryBuilder *insert(const std::string &table_name);
|
|
|
|
virtual QueryBuilder *values(const std::string ¶ms_str);
|
|
|
|
|
|
|
|
virtual QueryBuilder *eselect(const std::string ¶ms);
|
|
|
|
virtual QueryBuilder *ewhere(const std::string ¶ms);
|
|
|
|
virtual QueryBuilder *efrom(const std::string ¶ms);
|
|
|
|
virtual QueryBuilder *einsert(const std::string &table_name);
|
|
|
|
virtual QueryBuilder *evalues(const std::string ¶ms_str);
|
|
|
|
|
2020-12-01 21:48:13 +01:00
|
|
|
virtual QueryBuilder *limit(const int min, const int max);
|
2021-07-08 18:52:59 +02:00
|
|
|
|
2021-08-19 14:12:02 +02:00
|
|
|
virtual std::string escape(const std::string ¶ms);
|
|
|
|
|
|
|
|
virtual QueryBuilder *prepare();
|
|
|
|
virtual QueryBuilder *set_param(const int index, const std::string &value);
|
|
|
|
virtual QueryBuilder *set_param(const int index, const int value);
|
|
|
|
virtual QueryBuilder *set_param(const int index, const float value);
|
|
|
|
|
|
|
|
virtual void end_command();
|
|
|
|
|
|
|
|
virtual QueryResult *run();
|
|
|
|
|
|
|
|
std::string get_result();
|
2020-12-01 22:23:28 +01:00
|
|
|
|
2020-12-01 21:48:13 +01:00
|
|
|
QueryBuilder();
|
|
|
|
virtual ~QueryBuilder();
|
|
|
|
|
|
|
|
std::string query_result;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|