mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-05 20:42:10 +01:00
135 lines
4.2 KiB
C++
135 lines
4.2 KiB
C++
#ifndef QUERY_BUILDER_H
|
|
#define QUERY_BUILDER_H
|
|
|
|
#include "core/string.h"
|
|
|
|
#include "core/reference.h"
|
|
|
|
class QueryResult;
|
|
|
|
//methods that start with an e escape their params.
|
|
|
|
class QueryBuilder : public Reference {
|
|
RCPP_OBJECT(QueryBuilder, Reference);
|
|
|
|
public:
|
|
virtual QueryBuilder *select();
|
|
virtual QueryBuilder *update();
|
|
virtual QueryBuilder *del();
|
|
|
|
virtual QueryBuilder *where();
|
|
virtual QueryBuilder *from();
|
|
virtual QueryBuilder *insert();
|
|
virtual QueryBuilder *values();
|
|
virtual QueryBuilder *cvalues();
|
|
virtual QueryBuilder *next_value();
|
|
|
|
virtual QueryBuilder *begin_transaction();
|
|
virtual QueryBuilder *commit();
|
|
|
|
virtual QueryBuilder *nl();
|
|
|
|
virtual QueryBuilder *str();
|
|
virtual QueryBuilder *cstr();
|
|
|
|
virtual QueryBuilder *like();
|
|
|
|
virtual QueryBuilder *select(const String ¶ms);
|
|
virtual QueryBuilder *update(const String ¶ms);
|
|
virtual QueryBuilder *del(const String ¶ms);
|
|
|
|
virtual QueryBuilder *where(const String ¶ms);
|
|
virtual QueryBuilder *from(const String ¶ms);
|
|
virtual QueryBuilder *insert(const String &table_name);
|
|
virtual QueryBuilder *insert(const String &table_name, const String &columns);
|
|
virtual QueryBuilder *values(const String ¶ms_str);
|
|
virtual QueryBuilder *val();
|
|
virtual QueryBuilder *val(const String ¶m);
|
|
virtual QueryBuilder *val(const char *param);
|
|
virtual QueryBuilder *val(const int param);
|
|
virtual QueryBuilder *val(const bool param);
|
|
virtual QueryBuilder *valf(const float param);
|
|
virtual QueryBuilder *vald(const double param);
|
|
|
|
virtual QueryBuilder *like(const String &str);
|
|
|
|
virtual QueryBuilder *set();
|
|
virtual QueryBuilder *cset();
|
|
|
|
virtual QueryBuilder *setp(const String &col, const String ¶m);
|
|
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 *setpf(const String &col, const float param);
|
|
virtual QueryBuilder *setpd(const String &col, const double param);
|
|
|
|
virtual QueryBuilder *wp(const String &col, const String ¶m);
|
|
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 ¶ms);
|
|
virtual QueryBuilder *nupdate(const String ¶ms);
|
|
virtual QueryBuilder *ndel(const String ¶ms);
|
|
|
|
virtual QueryBuilder *nwhere(const String ¶ms);
|
|
virtual QueryBuilder *nfrom(const String ¶ms);
|
|
virtual QueryBuilder *nlike(const String &str);
|
|
virtual QueryBuilder *nvalues(const String ¶ms_str);
|
|
virtual QueryBuilder *nval(const String ¶m);
|
|
//note col is NOT escaped
|
|
virtual QueryBuilder *nsetp(const String &col, const String &escape_param);
|
|
//note col is NOT escaped
|
|
virtual QueryBuilder *nwp(const String &col, const String &escape_param);
|
|
|
|
virtual QueryBuilder *limit(const int num);
|
|
virtual QueryBuilder *offset(const int num);
|
|
|
|
virtual QueryBuilder *order_by_asc(const String &col);
|
|
virtual QueryBuilder *order_by_desc(const String &col);
|
|
virtual QueryBuilder *order_by(const String &col);
|
|
|
|
virtual QueryBuilder *order_by();
|
|
virtual QueryBuilder *corder_by();
|
|
virtual QueryBuilder *asc();
|
|
virtual QueryBuilder *desc();
|
|
virtual QueryBuilder *order_by_add_col(const String &col);
|
|
virtual QueryBuilder *asc(const String &col);
|
|
virtual QueryBuilder *desc(const String &col);
|
|
|
|
//l=logical (and, or are operators)
|
|
virtual QueryBuilder *land();
|
|
virtual QueryBuilder *lor();
|
|
|
|
virtual QueryBuilder *wildcard();
|
|
|
|
virtual QueryBuilder *w(const String &str);
|
|
virtual QueryBuilder *ew(const String &str);
|
|
|
|
virtual QueryBuilder *select_last_insert_id();
|
|
|
|
virtual String escape(const String ¶ms);
|
|
|
|
virtual QueryBuilder *prepare();
|
|
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);
|
|
|
|
virtual QueryBuilder *end_command();
|
|
|
|
virtual QueryBuilder *reset();
|
|
|
|
virtual Ref<QueryResult> run();
|
|
virtual void run_query();
|
|
|
|
String get_result();
|
|
|
|
void print();
|
|
|
|
QueryBuilder();
|
|
virtual ~QueryBuilder();
|
|
|
|
String query_result;
|
|
};
|
|
|
|
#endif |