|
@@ -15,12 +15,7 @@ class SqlBuilder {
|
|
|
* @return {void}
|
|
|
*/
|
|
|
constructor() {
|
|
|
- this.andWhere = [];
|
|
|
- this.orWhere = [];
|
|
|
- this.columns = [];
|
|
|
- this.limit = -1;
|
|
|
- this.offset = -1;
|
|
|
- this.orderBy = [];
|
|
|
+ this.resetCondition();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -38,6 +33,20 @@ class SqlBuilder {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 重置条件
|
|
|
+ *
|
|
|
+ * @return {void}
|
|
|
+ */
|
|
|
+ resetCondition() {
|
|
|
+ this.andWhere = [];
|
|
|
+ this.orWhere = [];
|
|
|
+ this.columns = [];
|
|
|
+ this.limit = -1;
|
|
|
+ this.offset = -1;
|
|
|
+ this.orderBy = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 构建sql
|
|
|
*
|
|
|
* @param {String} tableName - 表名
|
|
@@ -85,6 +94,9 @@ class SqlBuilder {
|
|
|
sql += ' ORDER BY ' + orderByString;
|
|
|
}
|
|
|
|
|
|
+ // 重置数据
|
|
|
+ this.resetCondition();
|
|
|
+
|
|
|
return [sql, sqlParam];
|
|
|
}
|
|
|
|