gf/contrib/drivers/dm/dm.go

54 lines
1.2 KiB
Go
Raw Normal View History

2022-09-26 22:11:13 +08:00
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
// Package dm implements gdb.Driver, which supports operations for database DM.
package dm
import (
_ "gitee.com/chunanyong/dm"
2022-09-26 22:11:13 +08:00
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
type Driver struct {
*gdb.Core
}
2023-02-14 09:45:29 +08:00
const (
quoteChar = `"`
)
2022-09-26 22:11:13 +08:00
func init() {
var (
err error
driverObj = New()
driverNames = g.SliceStr{"dm"}
)
for _, driverName := range driverNames {
if err = gdb.Register(driverName, driverObj); err != nil {
panic(err)
}
}
}
// New create and returns a driver that implements gdb.Driver, which supports operations for dm.
2022-09-26 22:11:13 +08:00
func New() gdb.Driver {
return &Driver{}
}
// New creates and returns a database object for dm.
2022-09-26 22:11:13 +08:00
func (d *Driver) New(core *gdb.Core, node *gdb.ConfigNode) (gdb.DB, error) {
return &Driver{
Core: core,
}, nil
}
// GetChars returns the security char for this type of database.
2022-09-26 22:11:13 +08:00
func (d *Driver) GetChars() (charLeft string, charRight string) {
2023-02-14 09:45:29 +08:00
return quoteChar, quoteChar
2022-09-26 22:11:13 +08:00
}