فهرست منبع

修改sql基础类

olym 7 سال پیش
والد
کامیت
ac4722add5
1فایلهای تغییر یافته به همراه18 افزوده شده و 6 حذف شده
  1. 18 6
      app/lib/sql_builder.js

+ 18 - 6
app/lib/sql_builder.js

@@ -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];
     }