v1.0.2 Latest Latest

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

Go to latest
Published: Jul 11, 2020 License: Apache-2.0 Imports: 10 Imported by: 0




This section is empty.


This section is empty.


func InitXormEngine

func InitXormEngine(url string, maxOpenConns int, maxIdleConns int, prefix string) (engine *xorm.Engine, err error)

InitXormEngine 初始化 Xorm Engine


type MySQL

type MySQL struct {
	// contains filtered or unexported fields

MySQL 操作封装

func InitMySQL

func InitMySQL(url string, maxOpenConns int, maxIdleConns int) (mysql *MySQL, err error)

InitMySQL 初始化mysql数据库链接 发生错误会中断程序运行

func (*MySQL) Close

func (mysql *MySQL) Close() error

Close 销毁数据库连接对象

func (*MySQL) Count

func (mysql *MySQL) Count(countsql string, args ...interface{}) int

Count 查询数量

func (*MySQL) Delete

func (mysql *MySQL) Delete(deletesql string, args ...interface{}) error

Delete 删除记录

func (*MySQL) Insert

func (mysql *MySQL) Insert(insertsql string, args ...interface{}) error

Insert 插入记录

func (*MySQL) Query

func (mysql *MySQL) Query(querysql string, args ...interface{}) ([]map[string]interface{}, error)

Query 执行查询操作,返回多行的查询操作

func (*MySQL) Query2Json

func (mysql *MySQL) Query2Json(querysql string, args ...interface{}) (jsonstr string, err error)

Query2Json 直接把查询结果转为json

func (*MySQL) State

func (mysql *MySQL) State()

State 获取连接池运行状况,并赋值到mysql对象

func (*MySQL) TransBegin

func (mysql *MySQL) TransBegin() (*sql.Tx, error)

TransBegin 开启事务

func (*MySQL) TransCommit

func (mysql *MySQL) TransCommit(tx *sql.Tx) error

TransCommit 提交事务

func (*MySQL) TransRollback

func (mysql *MySQL) TransRollback(tx *sql.Tx) error

TransRollback 提交事务

func (*MySQL) Update

func (mysql *MySQL) Update(updatesql string, args ...interface{}) error

Update 更新记录

Jump to

Keyboard shortcuts

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