|
|
@ -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 |
|
|
|