-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdbhandler.go
58 lines (45 loc) · 1.34 KB
/
dbhandler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) 2024, donnie <[email protected]>
// All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// github.com/donnie4w/gdao
package gdao
import (
"database/sql"
. "github.com/donnie4w/gdao/base"
"github.com/donnie4w/gdao/gdaoSlave"
)
type dbHandler struct {
gdbc gdbcHandle
}
func init() {
gdaoSlave.Newdbhandle = newdbhandle
}
func newdbhandle(db *sql.DB, dbtype DBType) DBhandle {
return &dbHandler{gdbc: newGdbcHandle(nil, db, dbtype)}
}
func (h *dbHandler) GetDB() *sql.DB {
return h.gdbc.GetDB()
}
func (h *dbHandler) Close() error {
return h.gdbc.Close()
}
func (h *dbHandler) GetDBType() DBType {
return h.gdbc.GetDBType()
}
func (h *dbHandler) GetTransaction() (r Transaction, err error) {
return NewTransactionWithDBhandle(h)
}
func (h *dbHandler) ExecuteQueryBean(sqlstr string, args ...any) *DataBean {
return h.gdbc.ExecuteQueryBean(sqlstr, args...)
}
func (h *dbHandler) ExecuteQueryBeans(sqlstr string, args ...any) (r *DataBeans) {
return h.gdbc.ExecuteQueryBeans(sqlstr, args...)
}
func (h *dbHandler) ExecuteUpdate(sqlstr string, args ...any) (sql.Result, error) {
return h.gdbc.ExecuteUpdate(sqlstr, args...)
}
func (h *dbHandler) ExecuteBatch(sqlstr string, args [][]any) (r []sql.Result, err error) {
return h.gdbc.ExecuteBatch(sqlstr, args)
}