#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 { 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 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 *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 *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); //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 void end_command(); virtual QueryBuilder *reset(); virtual Ref run(); virtual void run_query(); String get_result(); void print(); QueryBuilder(); virtual ~QueryBuilder(); String query_result; }; #endif