2020-12-01 21:48:13 +01:00
|
|
|
#include "query_builder.h"
|
|
|
|
|
2021-08-19 14:12:02 +02:00
|
|
|
#include "query_result.h"
|
|
|
|
|
|
|
|
QueryBuilder *QueryBuilder::select() {
|
|
|
|
return this;
|
|
|
|
}
|
2021-11-01 17:00:55 +01:00
|
|
|
QueryBuilder *QueryBuilder::update() {
|
2021-08-20 12:11:27 +02:00
|
|
|
return this;
|
|
|
|
}
|
2021-08-20 12:49:57 +02:00
|
|
|
QueryBuilder *QueryBuilder::del() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-08-19 14:12:02 +02:00
|
|
|
QueryBuilder *QueryBuilder::where() {
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
QueryBuilder *QueryBuilder::from() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
QueryBuilder *QueryBuilder::insert() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
QueryBuilder *QueryBuilder::values() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
QueryBuilder *QueryBuilder::cvalues() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-08-22 21:44:20 +02:00
|
|
|
QueryBuilder *QueryBuilder::str() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
QueryBuilder *QueryBuilder::cstr() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
QueryBuilder *QueryBuilder::like() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2020-12-01 21:48:13 +01:00
|
|
|
QueryBuilder *QueryBuilder::select(const std::string ¶ms) {
|
2021-11-01 17:23:08 +01:00
|
|
|
return nselect(escape(params));
|
2020-12-01 21:48:13 +01:00
|
|
|
}
|
2021-11-01 17:00:55 +01:00
|
|
|
QueryBuilder *QueryBuilder::update(const std::string ¶ms) {
|
2021-11-01 17:23:08 +01:00
|
|
|
return nupdate(escape(params));
|
2021-08-20 12:11:27 +02:00
|
|
|
}
|
2021-08-20 12:49:57 +02:00
|
|
|
QueryBuilder *QueryBuilder::del(const std::string ¶ms) {
|
2021-11-01 17:23:08 +01:00
|
|
|
return ndel(escape(params));
|
2021-08-20 12:49:57 +02:00
|
|
|
}
|
2020-12-01 21:48:13 +01:00
|
|
|
QueryBuilder *QueryBuilder::where(const std::string ¶ms) {
|
2021-11-01 17:23:08 +01:00
|
|
|
return nwhere(escape(params));
|
2020-12-01 21:48:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QueryBuilder *QueryBuilder::from(const std::string ¶ms) {
|
2021-11-01 17:23:08 +01:00
|
|
|
return nfrom(escape(params));
|
2020-12-01 21:48:13 +01:00
|
|
|
}
|
|
|
|
|
2021-08-19 14:12:02 +02:00
|
|
|
QueryBuilder *QueryBuilder::insert(const std::string &table_name) {
|
|
|
|
return this;
|
|
|
|
}
|
2021-08-20 01:32:43 +02:00
|
|
|
QueryBuilder *QueryBuilder::insert(const std::string &table_name, const std::string &columns) {
|
|
|
|
return this;
|
|
|
|
}
|
2021-08-19 14:12:02 +02:00
|
|
|
QueryBuilder *QueryBuilder::values(const std::string ¶ms_str) {
|
2021-11-01 17:23:08 +01:00
|
|
|
return nvalues(escape(params_str));
|
2021-08-19 14:12:02 +02:00
|
|
|
}
|
|
|
|
|
2021-08-20 01:32:43 +02:00
|
|
|
QueryBuilder *QueryBuilder::val() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
QueryBuilder *QueryBuilder::val(const std::string ¶m) {
|
2021-11-01 17:23:08 +01:00
|
|
|
return nval(escape(param));
|
2021-08-20 01:32:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QueryBuilder *QueryBuilder::val(const char *param) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
QueryBuilder *QueryBuilder::val(const int param) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
QueryBuilder *QueryBuilder::val(const bool param) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-08-22 21:44:20 +02:00
|
|
|
QueryBuilder *QueryBuilder::like(const std::string &str) {
|
2021-11-01 17:23:08 +01:00
|
|
|
return nlike(escape(str));
|
2021-08-22 21:44:20 +02:00
|
|
|
}
|
|
|
|
|
2021-08-20 12:11:27 +02:00
|
|
|
QueryBuilder *QueryBuilder::set() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
QueryBuilder *QueryBuilder::cset() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
QueryBuilder *QueryBuilder::setp(const std::string &col, const std::string ¶m) {
|
2021-11-01 17:23:08 +01:00
|
|
|
return nsetp(col, escape(param));
|
2021-08-20 12:11:27 +02:00
|
|
|
}
|
|
|
|
QueryBuilder *QueryBuilder::setp(const std::string &col, const char *param) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
QueryBuilder *QueryBuilder::setp(const std::string &col, const int param) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
QueryBuilder *QueryBuilder::setp(const std::string &col, const bool param) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-08-20 12:49:57 +02:00
|
|
|
QueryBuilder *QueryBuilder::wp(const std::string &col, const std::string ¶m) {
|
2021-11-01 17:23:08 +01:00
|
|
|
return nwp(col, escape(param));
|
2021-08-19 14:12:02 +02:00
|
|
|
}
|
2021-08-20 12:49:57 +02:00
|
|
|
QueryBuilder *QueryBuilder::wp(const std::string &col, const char *param) {
|
2021-08-20 12:11:27 +02:00
|
|
|
return this;
|
|
|
|
}
|
2021-08-20 12:49:57 +02:00
|
|
|
QueryBuilder *QueryBuilder::wp(const std::string &col, const int param) {
|
2021-08-19 14:12:02 +02:00
|
|
|
return this;
|
|
|
|
}
|
2021-08-20 12:49:57 +02:00
|
|
|
QueryBuilder *QueryBuilder::wp(const std::string &col, const bool param) {
|
2021-08-19 14:12:02 +02:00
|
|
|
return this;
|
|
|
|
}
|
2021-08-20 12:49:57 +02:00
|
|
|
|
2021-11-01 17:23:08 +01:00
|
|
|
QueryBuilder *QueryBuilder::nselect(const std::string ¶ms) {
|
|
|
|
return this;
|
2021-08-20 12:49:57 +02:00
|
|
|
}
|
2021-11-01 17:23:08 +01:00
|
|
|
QueryBuilder *QueryBuilder::nupdate(const std::string ¶ms) {
|
|
|
|
return this;
|
2021-08-20 12:49:57 +02:00
|
|
|
}
|
2021-11-01 17:23:08 +01:00
|
|
|
QueryBuilder *QueryBuilder::ndel(const std::string ¶ms) {
|
|
|
|
return this;
|
2021-08-20 12:49:57 +02:00
|
|
|
}
|
|
|
|
|
2021-11-01 17:23:08 +01:00
|
|
|
QueryBuilder *QueryBuilder::nwhere(const std::string ¶ms) {
|
|
|
|
return this;
|
2021-08-20 12:49:57 +02:00
|
|
|
}
|
2021-11-01 17:23:08 +01:00
|
|
|
QueryBuilder *QueryBuilder::nfrom(const std::string ¶ms) {
|
2021-08-19 14:12:02 +02:00
|
|
|
return this;
|
|
|
|
}
|
2021-11-01 17:23:08 +01:00
|
|
|
QueryBuilder *QueryBuilder::nlike(const std::string &str) {
|
|
|
|
return this;
|
2021-08-22 21:44:20 +02:00
|
|
|
}
|
2021-11-01 17:23:08 +01:00
|
|
|
QueryBuilder *QueryBuilder::nvalues(const std::string ¶ms_str) {
|
|
|
|
return this;
|
2021-08-19 14:12:02 +02:00
|
|
|
}
|
|
|
|
|
2021-11-01 17:23:08 +01:00
|
|
|
QueryBuilder *QueryBuilder::nval(const std::string ¶m) {
|
2021-08-20 12:49:57 +02:00
|
|
|
return val(escape(param));
|
|
|
|
}
|
2021-11-01 17:23:08 +01:00
|
|
|
QueryBuilder *QueryBuilder::nsetp(const std::string &col, const std::string &escape_param) {
|
2021-08-20 12:49:57 +02:00
|
|
|
return setp(col, escape(escape_param));
|
2021-08-20 01:32:43 +02:00
|
|
|
}
|
|
|
|
|
2021-11-01 17:23:08 +01:00
|
|
|
QueryBuilder *QueryBuilder::nwp(const std::string &col, const std::string &escape_param) {
|
|
|
|
return this;
|
2021-08-20 12:11:27 +02:00
|
|
|
}
|
2021-08-20 12:49:57 +02:00
|
|
|
|
2021-08-19 22:03:22 +02:00
|
|
|
QueryBuilder *QueryBuilder::limit(const int num) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
QueryBuilder *QueryBuilder::offset(const int num) {
|
2020-12-01 21:48:13 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-08-20 13:14:06 +02:00
|
|
|
QueryBuilder *QueryBuilder::land() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
QueryBuilder *QueryBuilder::lor() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-08-22 21:44:20 +02:00
|
|
|
QueryBuilder *QueryBuilder::wildcard() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-08-20 12:11:27 +02:00
|
|
|
QueryBuilder *QueryBuilder::w(const std::string &str) {
|
|
|
|
query_result += str + " ";
|
2021-08-20 12:49:57 +02:00
|
|
|
|
|
|
|
return this;
|
2021-08-20 12:11:27 +02:00
|
|
|
}
|
|
|
|
QueryBuilder *QueryBuilder::ew(const std::string &str) {
|
|
|
|
return w(escape(str));
|
|
|
|
}
|
|
|
|
|
2021-08-20 01:32:43 +02:00
|
|
|
QueryBuilder *QueryBuilder::select_last_insert_id() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-08-19 14:12:02 +02:00
|
|
|
std::string QueryBuilder::escape(const std::string ¶ms) {
|
|
|
|
return params;
|
|
|
|
}
|
|
|
|
|
|
|
|
QueryBuilder *QueryBuilder::prepare() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
QueryBuilder *QueryBuilder::set_param(const int index, const std::string &value) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
QueryBuilder *QueryBuilder::set_param(const int index, const int value) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
QueryBuilder *QueryBuilder::set_param(const int index, const float value) {
|
2020-12-01 21:48:13 +01:00
|
|
|
return this;
|
|
|
|
}
|
2020-12-01 22:23:28 +01:00
|
|
|
|
2021-08-19 14:12:02 +02:00
|
|
|
void QueryBuilder::end_command() {
|
|
|
|
}
|
|
|
|
|
2021-08-20 12:49:57 +02:00
|
|
|
QueryBuilder *QueryBuilder::reset() {
|
|
|
|
query_result = "";
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-11-01 16:57:22 +01:00
|
|
|
Ref<QueryResult> QueryBuilder::run() {
|
|
|
|
return Ref<QueryResult>();
|
2021-08-19 14:12:02 +02:00
|
|
|
}
|
|
|
|
|
2021-08-19 22:03:22 +02:00
|
|
|
void QueryBuilder::run_query() {
|
|
|
|
}
|
|
|
|
|
2021-08-19 14:12:02 +02:00
|
|
|
std::string QueryBuilder::get_result() {
|
|
|
|
end_command();
|
|
|
|
|
|
|
|
return query_result;
|
2020-12-01 22:23:28 +01:00
|
|
|
}
|
|
|
|
|
2021-08-20 01:32:43 +02:00
|
|
|
void QueryBuilder::print() {
|
|
|
|
printf("%s\n", query_result.c_str());
|
|
|
|
}
|
|
|
|
|
2020-12-01 21:48:13 +01:00
|
|
|
QueryBuilder::QueryBuilder() {
|
|
|
|
}
|
|
|
|
|
|
|
|
QueryBuilder::~QueryBuilder() {
|
|
|
|
}
|