mysql

package
v0.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfigs added in v0.0.9

func GetConfigs(name string) map[string]*Config

GetConfigs 获取配置项

func SetConfig added in v0.0.9

func SetConfig(name string, c map[string]any) error

SetIniConfig 配置

func SetIniConfig added in v0.0.12

func SetIniConfig(name string, section *ini.Section) error

SetIniConfig 设置 ini 配置

Types

type Config added in v0.0.10

type Config struct {
	// contains filtered or unexported fields
}

func GetConfig added in v0.0.9

func GetConfig(name string) (*Config, error)

GetConfig 获取配置项

type Driver added in v0.0.10

type Driver struct {
	*Executor
	// contains filtered or unexported fields
}

func GetDb added in v0.0.9

func GetDb(name string) (*Driver, error)

GetDb 获取数据库实例

func (*Driver) GetConfig added in v0.0.10

func (d *Driver) GetConfig() *Config

GetConfig 参数配置

func (*Driver) Init added in v0.0.10

func (d *Driver) Init() error

Init 初始化

func (*Driver) SetConfig added in v0.0.10

func (d *Driver) SetConfig(config *Config)

SetConfig 参数配置

func (*Driver) Tx added in v0.0.10

func (d *Driver) Tx() (*Executor, error)

Tx 开启事务

type Executor added in v0.0.10

type Executor struct {
	// contains filtered or unexported fields
}

func (*Executor) Delete added in v0.0.10

func (e *Executor) Delete(table string, where map[string]any) (sql.Result, error)

Delete 删除

func (*Executor) Exec added in v0.0.10

func (e *Executor) Exec(sq string, args ...any) (sql.Result, error)

Exec 执行,用于 insert / update / delete

func (*Executor) GetBind added in v0.0.10

func (e *Executor) GetBind(bind *any, sq string, args ...any) error

GetBind 查询记录, 缓定到指定对象

func (*Executor) GetMap added in v0.0.10

func (e *Executor) GetMap(sq string, args ...any) (map[string]string, error)

GetMap 查询一行记录

func (*Executor) GetMaps added in v0.0.10

func (e *Executor) GetMaps(sq string, args ...any) ([]map[string]string, error)

GetMaps 查询多行记录

func (*Executor) GetTable added in v0.0.10

func (e *Executor) GetTable(table string) *Table

GetTable 获取表记录

func (*Executor) GetTuple added in v0.0.10

func (e *Executor) GetTuple(table string) *Tuple

GetTuple 获取行记录

func (*Executor) GetValue added in v0.0.10

func (e *Executor) GetValue(sq string, args ...any) (string, error)

GetValue 查询一个字段的值

func (*Executor) GetValues added in v0.0.10

func (e *Executor) GetValues(sq string, args ...any) ([]string, error)

GetValues 查询一个字段的值

func (*Executor) Insert added in v0.0.10

func (e *Executor) Insert(table string, data map[string]any) (sql.Result, error)

Insert 插入数据

func (*Executor) Query added in v0.0.10

func (e *Executor) Query(sq string, args ...any) (*sql.Rows, error)

Query 查询,返回查询结果集,用于 select

func (*Executor) Truncate added in v0.0.10

func (e *Executor) Truncate(table string) (sql.Result, error)

Truncate 清空表

func (*Executor) Update added in v0.0.10

func (e *Executor) Update(table string, data map[string]any, primaryKeys ...string) (sql.Result, error)

Update 更新数据

type ExecutorType added in v0.0.10

type ExecutorType string
const (
	ExecutorTypeDb ExecutorType = "db"
	ExecutorTypeTx ExecutorType = "tx"
)

type Table added in v0.0.9

type Table struct {
	// contains filtered or unexported fields
}

func (*Table) Count added in v0.0.10

func (table *Table) Count(fields string) int

Count 获取总数

func (*Table) GetValue added in v0.0.10

func (table *Table) GetValue(fields string) string

GetValue 获取值

func (*Table) Init added in v0.0.10

func (table *Table) Init() *Table

Init 初始化

func (*Table) Limit added in v0.0.10

func (table *Table) Limit(limit int) *Table

Limit 读取条数,即分页大小

func (*Table) Offset added in v0.0.10

func (table *Table) Offset(offset int) *Table

Offset 编移量

func (*Table) OrderBy added in v0.0.10

func (table *Table) OrderBy(field string, dir string) *Table

OrderBy 排序

func (*Table) OrderByStr added in v0.0.10

func (table *Table) OrderByStr(orderBy string) *Table

OrderByStr 排序字符串

func (*Table) SetExecutor added in v0.0.10

func (table *Table) SetExecutor(e *Executor) *Table

SetExecutor 设置执行品

func (*Table) SetName added in v0.0.9

func (table *Table) SetName(name string) *Table

SetName 设置名称

func (*Table) SetStruct added in v0.0.10

func (table *Table) SetStruct(s any) *Table

SetStruct 设置结构

func (*Table) Where added in v0.0.10

func (table *Table) Where(params ...any) *Table

Where 查询条件

func (*Table) WhereGroup added in v0.0.10

func (table *Table) WhereGroup(params []any) *Table

WhereGroup 一组查询条件

type Tuple added in v0.0.9

type Tuple struct {
	// contains filtered or unexported fields
}

func (*Tuple) Init added in v0.0.10

func (tuple *Tuple) Init() *Tuple

Init 初始化

func (*Tuple) SetExecutor added in v0.0.10

func (tuple *Tuple) SetExecutor(e *Executor) *Tuple

SetExecutor 设置执行品

func (*Tuple) SetName added in v0.0.9

func (tuple *Tuple) SetName(name string)

SetName 设置名称

func (*Tuple) SetStruct added in v0.0.9

func (tuple *Tuple) SetStruct(s any)

SetStruct 设置结构

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL