1
This commit is contained in:
parent
9e85076c6d
commit
97d2608346
13
dbpool.go
13
dbpool.go
@ -7,6 +7,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DBStyle int32
|
type DBStyle int32
|
||||||
@ -243,6 +244,10 @@ func (this *dbPool) joinInsertFields(fieldsKv [][]string, params *[]string) stri
|
|||||||
func (this *dbPool) internalExec(dataSource string, sql string, params []string,
|
func (this *dbPool) internalExec(dataSource string, sql string, params []string,
|
||||||
cb ExecResultCb) {
|
cb ExecResultCb) {
|
||||||
ds := this.borrowConn(dataSource)
|
ds := this.borrowConn(dataSource)
|
||||||
|
if ds == nil {
|
||||||
|
cb(errors.New("borrowConn error"), int64(0), int64(0))
|
||||||
|
return
|
||||||
|
}
|
||||||
result, err := ds.conn.Exec(sql, q5.ToInterfaces(params)...)
|
result, err := ds.conn.Exec(sql, q5.ToInterfaces(params)...)
|
||||||
this.returnConn(ds)
|
this.returnConn(ds)
|
||||||
|
|
||||||
@ -269,6 +274,10 @@ func (this *dbPool) internalExec(dataSource string, sql string, params []string,
|
|||||||
func (this *dbPool) internalQuery(dataSource string, sql string, params []string,
|
func (this *dbPool) internalQuery(dataSource string, sql string, params []string,
|
||||||
cb QueryResultCb) {
|
cb QueryResultCb) {
|
||||||
ds := this.borrowConn(dataSource)
|
ds := this.borrowConn(dataSource)
|
||||||
|
if ds == nil {
|
||||||
|
cb(errors.New("borrowConn error"), int64(0), int64(0))
|
||||||
|
return
|
||||||
|
}
|
||||||
rows, err := ds.conn.Query(sql, q5.ToInterfaces(params)...)
|
rows, err := ds.conn.Query(sql, q5.ToInterfaces(params)...)
|
||||||
this.returnConn(ds)
|
this.returnConn(ds)
|
||||||
|
|
||||||
@ -285,6 +294,10 @@ func (this *dbPool) internalQuery(dataSource string, sql string, params []string
|
|||||||
func (this *dbPool) internalQueryOne(dataSource string, sql string, params []string,
|
func (this *dbPool) internalQueryOne(dataSource string, sql string, params []string,
|
||||||
cb QueryOneCb) {
|
cb QueryOneCb) {
|
||||||
ds := this.borrowConn(dataSource)
|
ds := this.borrowConn(dataSource)
|
||||||
|
if ds == nil {
|
||||||
|
cb(errors.New("borrowConn error"), int64(0), int64(0))
|
||||||
|
return
|
||||||
|
}
|
||||||
rows, err := ds.conn.Query(sql, q5.ToInterfaces(params)...)
|
rows, err := ds.conn.Query(sql, q5.ToInterfaces(params)...)
|
||||||
this.returnConn(ds)
|
this.returnConn(ds)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user