Selaa lähdekoodia

添加 查询 in操作

wangshan 5 vuotta sitten
vanhempi
commit
2b4e4dc988
1 muutettua tiedostoa jossa 13 lisäystä ja 0 poistoa
  1. 13 0
      src/qfw/util/mysql/mysql.go

+ 13 - 0
src/qfw/util/mysql/mysql.go

@@ -198,6 +198,19 @@ func (m *Mysql) Find(tableName string, query map[string]interface{}, fields, ord
 						}
 					}
 				}
+				if rv_k.String() == "in" {
+					if len(rv.MapIndex(rv_k).Interface().([]interface{})) > 0 {
+						_fs := fmt.Sprintf("%s in (?", k)
+						for k, v := range rv.MapIndex(rv_k).Interface().([]interface{}) {
+							if k > 0 {
+								_fs += ",?"
+							}
+							vs = append(vs, v)
+						}
+						_fs += ")"
+						fs = append(fs, _fs)
+					}
+				}
 			}
 		} else {
 			if v == "$isNull" {