mysql

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Db

type Db struct {
	DbConn *DbConnection
	// DbQuery  DbQuery
	Dbconfig *map[string]interface{}
}

func (*Db) Db

func (db *Db) Db(table string) *ExQuery

type DbConnection

type DbConnection struct {
	DB       *sql.DB
	DbPrefix string
	DbName   string
	DbConf   map[string]string
}

创建连接器

func (*DbConnection) Connt

func (DbConnection *DbConnection) Connt(cnt *map[string]string) error

构建连接

type DbQuery

type DbQuery struct {
	DB       *sql.DB
	Prefix   string
	Executor *ExQuery
	sync.RWMutex
}

构建查询器

func (*DbQuery) Builder

func (q *DbQuery) Builder(dbConnection *DbConnection)

dbConnection.DB.PingContext(ctx) 防止ping阻塞

type ExQuery added in v1.0.11

type ExQuery struct {
	Wher string

	Joinn string

	Rows   interface{}
	Row    interface{}
	Prefix string
	DB     *sql.DB
	Ctx    context.Context
	Tx     *sql.Tx
	sync.RWMutex
	// contains filtered or unexported fields
}

执行器

func (*ExQuery) Alias added in v1.0.11

func (q *ExQuery) Alias(alias string) *ExQuery

func (*ExQuery) Clearquery added in v1.0.11

func (sqlstruct *ExQuery) Clearquery()

func (*ExQuery) Count added in v1.0.11

func (q *ExQuery) Count() (int, error)

func (*ExQuery) CreateDBTx added in v1.0.11

func (q *ExQuery) CreateDBTx() (*ExQuery, error)

创建事务 注意,不能用q.DB.Conn(ctx) 否则会创建 新的连接并不会释放

func (*ExQuery) Del added in v1.0.11

func (q *ExQuery) Del() (sql.Result, error)

func (*ExQuery) Exec added in v1.0.11

func (q *ExQuery) Exec(sql string, args ...interface{}) (sql.Result, error)

func (*ExQuery) Field added in v1.0.11

func (q *ExQuery) Field(field string) *ExQuery

func (*ExQuery) Find added in v1.0.11

func (q *ExQuery) Find() (map[string]interface{}, error)

func (*ExQuery) Fun added in v1.0.14

func (q *ExQuery) Fun(f func(query *ExQuery) *ExQuery) *ExQuery

闭包查询

func (*ExQuery) GetRow added in v1.0.11

func (q *ExQuery) GetRow(query *sql.Rows) map[string]interface{}

func (*ExQuery) GetRows added in v1.0.11

func (q *ExQuery) GetRows(query *sql.Rows) []map[string]interface{}

func (*ExQuery) Group added in v1.0.11

func (q *ExQuery) Group(group string) *ExQuery

func (*ExQuery) Having added in v1.0.11

func (q *ExQuery) Having(h string, v interface{}) *ExQuery

func (*ExQuery) In added in v1.0.11

func (q *ExQuery) In(in string, v []interface{}) *ExQuery

func (*ExQuery) Join added in v1.0.11

func (q *ExQuery) Join(jType string, table string, on string) *ExQuery

涉及线程安全,改用字符串

func (*ExQuery) Limit added in v1.0.11

func (q *ExQuery) Limit(limit string) *ExQuery

func (*ExQuery) Or added in v1.0.11

func (q *ExQuery) Or(or string, v ...interface{}) *ExQuery

func (*ExQuery) OrIn added in v1.0.11

func (q *ExQuery) OrIn(in string, v []interface{}) *ExQuery

func (*ExQuery) Order added in v1.0.11

func (q *ExQuery) Order(order string) *ExQuery

func (*ExQuery) Query added in v1.0.11

func (q *ExQuery) Query(sql string, args ...interface{}) ([]map[string]interface{}, error)

func (*ExQuery) Save added in v1.0.11

func (q *ExQuery) Save(save map[string]interface{}) (sql.Result, error)

func (*ExQuery) Select added in v1.0.11

func (q *ExQuery) Select() ([]map[string]interface{}, error)

func (*ExQuery) SelectSql added in v1.0.11

func (q *ExQuery) SelectSql() string

func (*ExQuery) Size added in v1.0.11

func (q *ExQuery) Size(page int, size int) *ExQuery

func (*ExQuery) Table added in v1.0.11

func (q *ExQuery) Table(table string) *ExQuery

func (*ExQuery) TxCommit added in v1.0.16

func (q *ExQuery) TxCommit() error

事务提交

func (*ExQuery) TxRollback added in v1.0.16

func (q *ExQuery) TxRollback() error

事务回滚

func (*ExQuery) TxSave added in v1.0.11

func (q *ExQuery) TxSave(save map[string]interface{}) (sql.Result, error)

事务写入

func (*ExQuery) TxUpdate added in v1.0.11

func (q *ExQuery) TxUpdate(update map[string]interface{}, where ...interface{}) (sql.Result, error)

事务更新

func (*ExQuery) Update added in v1.0.11

func (q *ExQuery) Update(update map[string]interface{}) (sql.Result, error)

func (*ExQuery) Value added in v1.0.11

func (q *ExQuery) Value(key string) (interface{}, error)

func (*ExQuery) Where added in v1.0.11

func (q *ExQuery) Where(wher string, v ...interface{}) *ExQuery

func (*ExQuery) WhereOr added in v1.0.17

func (q *ExQuery) WhereOr(f func(query *ExQuery) *ExQuery) *ExQuery

使用此方法时 请优先于任何where条件执行

Jump to

Keyboard shortcuts

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