Browse Source

修改查询条件,兼容不同服务商数据库

master v0.11.0
guzeng 1 year ago
parent
commit
16ae9b2dbe
3 changed files with 18 additions and 5 deletions
  1. +5
    -1
      chain.go
  2. +3
    -0
      conn.go
  3. +10
    -4
      db.go

+ 5
- 1
chain.go View File

@ -266,7 +266,11 @@ func (this *Query) BuildSelectSql() (map[string]interface{}, error) {
} else {
title = "*"
}
sql = helper.StringJoin("/*slave*/ select ", title)
if DB_PROVIDER == "TencentDB" {
sql = helper.StringJoin("/*slave*/ select ", title)
} else {
sql = helper.StringJoin("select ", title)
}
if this.alias != "" {
table = helper.StringJoin(table, " as ", this.alias)


+ 3
- 0
conn.go View File

@ -17,6 +17,9 @@ var DB *sql.DB
var SLAVER_DB *sql.DB
//db类型,默认空,如TencentDB(腾讯),
var DB_PROVIDER string
func Connect(DBHOST, DBUSER, DBPWD, DBNAME, DBPORT string, conns ...int) error {
log.Println("database connectting...")


+ 10
- 4
db.go View File

@ -316,8 +316,11 @@ func GetRow(dbName, table_name, alias string, titles string, join [][]string, wh
} else {
title = "*"
}
sql_str = helper.StringJoin("/*slave*/ select ", title)
if DB_PROVIDER == "TencentDB" {
sql_str = helper.StringJoin("/*slave*/ select ", title)
} else {
sql_str = helper.StringJoin("select ", title)
}
if alias != "" {
table = helper.StringJoin(table, " as ", alias)
}
@ -463,8 +466,11 @@ func FetchRows(dbName, table_name, alias string, titles string, join [][]string,
} else {
title = "*"
}
sql_str = helper.StringJoin("/*slave*/ select ", title)
if DB_PROVIDER == "TencentDB" {
sql_str = helper.StringJoin("/*slave*/ select ", title)
} else {
sql_str = helper.StringJoin("select ", title)
}
if alias != "" {
table = helper.StringJoin(table, " as ", alias)
}


Loading…
Cancel
Save