rcpp_framework/core/database/query_builder.h

117 lines
3.5 KiB
C
Raw Normal View History

#ifndef QUERY_BUILDER_H
#define QUERY_BUILDER_H
2021-11-01 17:31:04 +01:00
#include "core/string.h"
#include "core/reference.h"
class QueryResult;
//methods that start with an e escape their params.
class QueryBuilder : public Reference {
public:
virtual QueryBuilder *select();
2021-11-01 17:00:55 +01:00
virtual QueryBuilder *update();
2021-08-20 12:49:57 +02:00
virtual QueryBuilder *del();
2021-08-20 12:49:57 +02:00
virtual QueryBuilder *where();
virtual QueryBuilder *from();
virtual QueryBuilder *insert();
virtual QueryBuilder *values();
virtual QueryBuilder *cvalues();
2021-11-14 19:22:49 +01:00
virtual QueryBuilder *next_value();
virtual QueryBuilder *begin_transaction();
virtual QueryBuilder *commit();
virtual QueryBuilder *nl();
2021-08-22 21:44:20 +02:00
virtual QueryBuilder *str();
virtual QueryBuilder *cstr();
virtual QueryBuilder *like();
2021-11-01 17:31:04 +01:00
virtual QueryBuilder *select(const String &params);
virtual QueryBuilder *update(const String &params);
virtual QueryBuilder *del(const String &params);
2021-08-20 12:49:57 +02:00
2021-11-01 17:31:04 +01:00
virtual QueryBuilder *where(const String &params);
virtual QueryBuilder *from(const String &params);
virtual QueryBuilder *insert(const String &table_name);
virtual QueryBuilder *insert(const String &table_name, const String &columns);
virtual QueryBuilder *values(const String &params_str);
virtual QueryBuilder *val();
2021-11-01 17:31:04 +01:00
virtual QueryBuilder *val(const String &param);
virtual QueryBuilder *val(const char *param);
virtual QueryBuilder *val(const int param);
virtual QueryBuilder *val(const bool param);
2021-11-01 17:31:04 +01:00
virtual QueryBuilder *like(const String &str);
2021-08-22 21:44:20 +02:00
virtual QueryBuilder *set();
virtual QueryBuilder *cset();
2021-11-01 17:31:04 +01:00
virtual QueryBuilder *setp(const String &col, const String &param);
virtual QueryBuilder *setp(const String &col, const char *param);
virtual QueryBuilder *setp(const String &col, const int param);
virtual QueryBuilder *setp(const String &col, const bool param);
virtual QueryBuilder *wp(const String &col, const String &param);
virtual QueryBuilder *wp(const String &col, const char *param);
virtual QueryBuilder *wp(const String &col, const int param);
virtual QueryBuilder *wp(const String &col, const bool param);
virtual QueryBuilder *nselect(const String &params);
virtual QueryBuilder *nupdate(const String &params);
virtual QueryBuilder *ndel(const String &params);
virtual QueryBuilder *nwhere(const String &params);
virtual QueryBuilder *nfrom(const String &params);
virtual QueryBuilder *nlike(const String &str);
virtual QueryBuilder *nvalues(const String &params_str);
virtual QueryBuilder *nval(const String &param);
//note col is NOT escaped
2021-11-01 17:31:04 +01:00
virtual QueryBuilder *nsetp(const String &col, const String &escape_param);
2021-08-20 12:49:57 +02:00
//note col is NOT escaped
2021-11-01 17:31:04 +01:00
virtual QueryBuilder *nwp(const String &col, const String &escape_param);
2021-08-19 22:03:22 +02:00
virtual QueryBuilder *limit(const int num);
virtual QueryBuilder *offset(const int num);
//l=logical (and, or are operators)
virtual QueryBuilder *land();
virtual QueryBuilder *lor();
2021-08-22 21:44:20 +02:00
virtual QueryBuilder *wildcard();
2021-11-01 17:31:04 +01:00
virtual QueryBuilder *w(const String &str);
virtual QueryBuilder *ew(const String &str);
virtual QueryBuilder *select_last_insert_id();
2021-11-01 17:31:04 +01:00
virtual String escape(const String &params);
virtual QueryBuilder *prepare();
2021-11-01 17:31:04 +01:00
virtual QueryBuilder *set_param(const int index, const String &value);
virtual QueryBuilder *set_param(const int index, const int value);
virtual QueryBuilder *set_param(const int index, const float value);
2021-11-14 19:22:49 +01:00
virtual QueryBuilder *end_command();
2021-08-20 12:49:57 +02:00
virtual QueryBuilder *reset();
virtual Ref<QueryResult> run();
2021-08-19 22:03:22 +02:00
virtual void run_query();
2021-11-01 17:31:04 +01:00
String get_result();
2020-12-01 22:23:28 +01:00
void print();
QueryBuilder();
virtual ~QueryBuilder();
2021-11-01 17:31:04 +01:00
String query_result;
};
#endif