Browse Source

兼容多表名的情况

master v0.11.1
zhenghaorong 1 year ago
parent
commit
373438a283
1 changed files with 11 additions and 2 deletions
  1. +11
    -2
      conn.go

+ 11
- 2
conn.go View File

@ -17,7 +17,7 @@ var DB *sql.DB
var SLAVER_DB *sql.DB
//db类型,默认空,如TencentDB(腾讯),
// db类型,默认空,如TencentDB(腾讯),
var DB_PROVIDER string
func Connect(DBHOST, DBUSER, DBPWD, DBNAME, DBPORT string, conns ...int) error {
@ -123,7 +123,16 @@ func getTableName(dbName, table string, dbtype ...string) string {
ret = table
}
if dbName != "" {
ret = helper.StringJoin(dbName, ".", table)
if strings.Contains(table, ",") {
arr := strings.Split(table, ",")
arrStrs := make([]string, 0, len(arr))
for _, v := range arr {
arrStrs = append(arrStrs, helper.StringJoin(dbName, ".", v))
}
ret = strings.Join(arrStrs, ",")
} else {
ret = helper.StringJoin(dbName, ".", table)
}
} else {
ret = table
}


Loading…
Cancel
Save