mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
111 lines
3.5 KiB
C++
111 lines
3.5 KiB
C++
#ifndef QUERY_BUILDER_H
|
|
#define QUERY_BUILDER_H
|
|
|
|
#include <string>
|
|
|
|
#include "core/reference.h"
|
|
|
|
class QueryResult;
|
|
|
|
//methods that start with an e escape their params.
|
|
|
|
class QueryBuilder : public 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 *str();
|
|
virtual QueryBuilder *cstr();
|
|
|
|
virtual QueryBuilder *like();
|
|
|
|
virtual QueryBuilder *select(const std::string ¶ms);
|
|
virtual QueryBuilder *update(const std::string ¶ms);
|
|
virtual QueryBuilder *del(const std::string ¶ms);
|
|
|
|
virtual QueryBuilder *where(const std::string ¶ms);
|
|
virtual QueryBuilder *from(const std::string ¶ms);
|
|
virtual QueryBuilder *insert(const std::string &table_name);
|
|
virtual QueryBuilder *insert(const std::string &table_name, const std::string &columns);
|
|
virtual QueryBuilder *values(const std::string ¶ms_str);
|
|
virtual QueryBuilder *val();
|
|
virtual QueryBuilder *val(const std::string ¶m);
|
|
virtual QueryBuilder *val(const char *param);
|
|
virtual QueryBuilder *val(const int param);
|
|
virtual QueryBuilder *val(const bool param);
|
|
|
|
virtual QueryBuilder *like(const std::string &str);
|
|
|
|
virtual QueryBuilder *set();
|
|
virtual QueryBuilder *cset();
|
|
|
|
virtual QueryBuilder *setp(const std::string &col, const std::string ¶m);
|
|
virtual QueryBuilder *setp(const std::string &col, const char *param);
|
|
virtual QueryBuilder *setp(const std::string &col, const int param);
|
|
virtual QueryBuilder *setp(const std::string &col, const bool param);
|
|
|
|
virtual QueryBuilder *wp(const std::string &col, const std::string ¶m);
|
|
virtual QueryBuilder *wp(const std::string &col, const char *param);
|
|
virtual QueryBuilder *wp(const std::string &col, const int param);
|
|
virtual QueryBuilder *wp(const std::string &col, const bool param);
|
|
|
|
virtual QueryBuilder *nselect(const std::string ¶ms);
|
|
virtual QueryBuilder *nupdate(const std::string ¶ms);
|
|
virtual QueryBuilder *ndel(const std::string ¶ms);
|
|
|
|
virtual QueryBuilder *nwhere(const std::string ¶ms);
|
|
virtual QueryBuilder *nfrom(const std::string ¶ms);
|
|
virtual QueryBuilder *nlike(const std::string &str);
|
|
virtual QueryBuilder *nvalues(const std::string ¶ms_str);
|
|
virtual QueryBuilder *nval(const std::string ¶m);
|
|
//note col is NOT escaped
|
|
virtual QueryBuilder *nsetp(const std::string &col, const std::string &escape_param);
|
|
//note col is NOT escaped
|
|
virtual QueryBuilder *nwp(const std::string &col, const std::string &escape_param);
|
|
|
|
virtual QueryBuilder *limit(const int num);
|
|
virtual QueryBuilder *offset(const int num);
|
|
|
|
//l=logical (and, or are operators)
|
|
virtual QueryBuilder *land();
|
|
virtual QueryBuilder *lor();
|
|
|
|
virtual QueryBuilder *wildcard();
|
|
|
|
virtual QueryBuilder *w(const std::string &str);
|
|
virtual QueryBuilder *ew(const std::string &str);
|
|
|
|
virtual QueryBuilder *select_last_insert_id();
|
|
|
|
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 QueryBuilder *reset();
|
|
|
|
virtual Ref<QueryResult> run();
|
|
virtual void run_query();
|
|
|
|
std::string get_result();
|
|
|
|
void print();
|
|
|
|
QueryBuilder();
|
|
virtual ~QueryBuilder();
|
|
|
|
std::string query_result;
|
|
};
|
|
|
|
#endif |