diff --git a/dbpool.go b/dbpool.go index c9ce380..7b8abcb 100644 --- a/dbpool.go +++ b/dbpool.go @@ -89,6 +89,31 @@ func (this *dbPool) SelectCustomQuery(dataSource string, sql string, cb QueryRes this.internalQuery(dataSource, sql, params, cb) } +func (this *dbPool) SyncSelectCustomQuery(dataSource string, sql string, cb QueryResultCb) { + chDone := make(chan bool) + params := []string{} + if this.style == GO_STYLE_DB { + go this.internalQuery(dataSource, sql, params, + func(err error, ds *DataSet) { + cb(err, ds) + chDone <- true + }) + } else { + this.internalQuery(dataSource, sql, params, + func(err error, ds *DataSet) { + cb(err, ds) + chDone <- true + }) + } + for { + select { + case <-chDone: + close(chDone) + return + } + } +} + func (this *dbPool) SelectLike( dataSource string, tblName string,