1 Star 3 Fork 1

Joshua Conero / uymas

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
xsql.go 786 Bytes
一键复制 编辑 原始数据 按行查看 历史
Joshua Conero 提交于 2022-09-12 23:38 . doc: gofmt interface{} -> any
// Package xsql extends for the sql package.
// power by <Joshua Conero>(2020)
package xsql
import (
"database/sql"
"fmt"
)
type Config struct {
TablePrefix string
DbType string
}
type Xsql struct {
cfg Config
conn *sql.DB
query *Query
}
func (x *Xsql) Name(tb string, alias ...string) *Builder {
return Table(fmt.Sprintf("%s%s", x.cfg.TablePrefix, tb), alias...)
}
func (x *Xsql) SelectFunc(call func(*Builder), tb string, alias ...string) ([]map[string]any, error) {
table := x.Name(tb, alias...)
if call != nil {
call(table)
}
bSql, bind := table.ToSQL()
return x.query.Select(bSql, bind...)
}
func NewXsql(conn *sql.DB, cfgs ...Config) *Xsql {
x := &Xsql{
conn: conn,
query: NewQuery(conn),
}
if len(cfgs) > 0 {
x.cfg = cfgs[0]
}
return x
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/conero/uymas.git
git@gitee.com:conero/uymas.git
conero
uymas
uymas
v1.4.0

搜索帮助

344bd9b3 5694891 D2dac590 5694891