Browse Source

修改GetRow查询方法

master v0.8.1
guzeng 2 years ago
parent
commit
07e9c8a562
1 changed files with 18 additions and 2 deletions
  1. +18
    -2
      db.go

+ 18
- 2
db.go View File

@ -356,9 +356,19 @@ func GetRow(dbName, table_name, alias string, titles string, join [][]string, wh
var err error
var queryNum int = 0
sql_str = helper.StringJoin(sql_str, " limit 1")
var db *sql.DB
if SLAVER_DB != nil {
db = SLAVER_DB
} else {
db = DB
}
for queryNum < 2 { //如发生错误,继续查询2次,防止数据库连接断开问题
rows, err = SLAVER_DB.Query(sql_str, valueList...)
rows, err = db.Query(sql_str, valueList...)
if err == nil {
break
@ -495,12 +505,18 @@ func FetchRows(dbName, table_name, alias string, titles string, join [][]string,
return 0, list, errors.New("参数错误,条件值错误")
}
var db *sql.DB
if SLAVER_DB != nil {
db = SLAVER_DB
} else {
db = DB
}
var rows *sql.Rows
var err error
var queryNum int = 0
for queryNum < 2 { //如发生错误,继续查询2次,防止数据库连接断开问题
rows, err = SLAVER_DB.Query(sql_str, valueList...)
rows, err = db.Query(sql_str, valueList...)
if err == nil {
break


Loading…
Cancel
Save