Added more helpers to QueryBuilder.

This commit is contained in:
Relintai 2021-11-14 19:22:49 +01:00
parent 1ec66db3c7
commit 1bd90ceb4a
6 changed files with 55 additions and 7 deletions

View File

@ -28,6 +28,22 @@ QueryBuilder *QueryBuilder::values() {
QueryBuilder *QueryBuilder::cvalues() {
return this;
}
QueryBuilder *QueryBuilder::next_value() {
return this;
}
QueryBuilder *QueryBuilder::begin_transaction() {
return this;
}
QueryBuilder *QueryBuilder::commit() {
return this;
}
QueryBuilder *QueryBuilder::nl() {
query_result += "\n";
return this;
}
QueryBuilder *QueryBuilder::str() {
return this;
@ -176,7 +192,7 @@ QueryBuilder *QueryBuilder::wildcard() {
}
QueryBuilder *QueryBuilder::w(const String &str) {
query_result += str + " ";
query_result += str;
return this;
}
@ -205,7 +221,8 @@ QueryBuilder *QueryBuilder::set_param(const int index, const float value) {
return this;
}
void QueryBuilder::end_command() {
QueryBuilder *QueryBuilder::end_command() {
return this;
}
QueryBuilder *QueryBuilder::reset() {

View File

@ -20,6 +20,12 @@ public:
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();
@ -91,7 +97,7 @@ public:
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 *end_command();
virtual QueryBuilder *reset();

View File

@ -88,8 +88,10 @@ QueryBuilder *MysqlQueryBuilder::set_param(const int index, const float value) {
return this;
}
void MysqlQueryBuilder::end_command() {
QueryBuilder *MysqlQueryBuilder::end_command() {
query_result += ";";
return this;
}
Ref<QueryResult> MysqlQueryBuilder::run() {

View File

@ -34,7 +34,7 @@ public:
QueryBuilder *set_param(const int index, const int value);
QueryBuilder *set_param(const int index, const float value);
void end_command();
QueryBuilder *end_command();
Ref<QueryResult> run();
void run_query();

View File

@ -47,6 +47,23 @@ QueryBuilder *SQLite3QueryBuilder::cvalues() {
return this;
}
QueryBuilder *SQLite3QueryBuilder::next_value() {
query_result[query_result.size() - 2] = ' ';
query_result += "), (";
return this;
}
QueryBuilder *SQLite3QueryBuilder::begin_transaction() {
query_result += "BEGIN TRANSACTION;";
return this;
}
QueryBuilder *SQLite3QueryBuilder::commit() {
query_result += "COMMIT;";
return this;
}
QueryBuilder *SQLite3QueryBuilder::str() {
query_result += "'";
@ -278,8 +295,10 @@ QueryBuilder *SQLite3QueryBuilder::set_param(const int index, const float value)
return this;
}
void SQLite3QueryBuilder::end_command() {
QueryBuilder *SQLite3QueryBuilder::end_command() {
query_result += ";";
return this;
}
Ref<QueryResult> SQLite3QueryBuilder::run() {

View File

@ -19,6 +19,10 @@ public:
QueryBuilder *insert();
QueryBuilder *values();
QueryBuilder *cvalues();
QueryBuilder *next_value();
QueryBuilder *begin_transaction();
QueryBuilder *commit();
QueryBuilder *str();
QueryBuilder *cstr();
@ -72,7 +76,7 @@ public:
QueryBuilder *set_param(const int index, const int value);
QueryBuilder *set_param(const int index, const float value);
void end_command();
QueryBuilder *end_command();
Ref<QueryResult> run();
void run_query();