Documentation ¶
Overview ¶
*
- DB transaction
Index ¶
- Variables
- func CloseConn() error
- func CloseStmt(stmt *sql.Stmt) error
- func Connect(DBHOST, DBUSER, DBPWD, DBNAME, DBPORT string, conns ...int) error
- func Delete(dbName, table string, data map[string]string, del_count ...string) (int64, error)
- func DoQuery(args ...interface{}) ([]map[string]string, error)
- func GetCount(dbName, table string, where map[string]string, args ...string) (total int)
- func GetData(dbName, table string, title string, where map[string]string, ...) (int, map[string]string, error)
- func GetDataByStmt(dbName string, table string, title string, where []string, ...) (map[string]string, error)
- func GetDbTableName(dbName, table string) string
- func GetInfo(dbName, table string, title string, where map[string]string) (map[string]string, error)
- func GetJoinListByStmt(dbName string, tableA, tableA_alias string, tableB, tableB_alias string, ...) ([]map[string]string, error)
- func GetList(dbName, table string, title string, where map[string]string, ...) ([]map[string]string, error)
- func GetListByStmt(dbName string, table string, title string, where []string, ...) ([]map[string]string, error)
- func GetTotal(dbName, table string, args ...string) (total int)
- func Insert(dbName, table string, data map[string]string) (int64, error)
- func InsertByStmt(dbName string, table string, data []string, valuelist []interface{}) (int64, error)
- func LeftJoinListByStmt(dbName string, tableA, tableB string, join_on string, title string, ...) ([]map[string]string, error)
- func QueryByStmt(sql string, valuelist []interface{}) ([]map[string]string, error)
- func StmtForInsert(dbName, table string, data []string) (*sql.Stmt, error)
- func StmtForInsertExec(stmt *sql.Stmt, valuelist []interface{}) (int64, error)
- func StmtForQuery(querysql string) (*sql.Stmt, error)
- func StmtForQueryList(stmt *sql.Stmt, valuelist []interface{}) ([]map[string]string, error)
- func StmtForQueryRow(stmt *sql.Stmt, valuelist []interface{}) (map[string]string, error)
- func StmtForRead(dbName, table string, title string, where []string, limit map[string]string) (*sql.Stmt, error)
- func StmtForUpdate(dbName, table string, data []string, where []string) (*sql.Stmt, error)
- func StmtForUpdateExec(stmt *sql.Stmt, valuelist []interface{}) (int64, error)
- func TxDelete(tx *sql.Tx, dbname, table string, where map[string]string, del_count ...string) (int64, error)
- func TxForRead(tx *sql.Tx, dbName, table string, title string, where []string) (*sql.Stmt, error)
- func TxGetData(tx *sql.Tx, dbName string, table string, title string, where []string, ...) (map[string]string, error)
- func TxInsert(tx *sql.Tx, dbname, table string, data map[string]string) (int64, error)
- func TxPreInsert(tx *sql.Tx, dbname, table string, data map[string]interface{}) (int64, error)
- func TxPreUpdate(tx *sql.Tx, dbname, table string, data []string, where []string, ...) (int64, error)
- func TxUpdate(tx *sql.Tx, dbname, table string, data map[string]string, ...) (int64, error)
- func Update(dbName, table string, data map[string]string, where map[string]string) (int64, error)
- func UpdateByStmt(dbName string, table string, data []string, where []string, ...) (int64, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var DB *sql.DB
Functions ¶
func GetData ¶
func GetData(dbName, table string, title string, where map[string]string, limit map[string]string) (int, map[string]string, error)
*
- 查找一条记录
- @param dbName 数据表名
- @param title 查询字段名
func GetDataByStmt ¶
func GetDataByStmt(dbName string, table string, title string, where []string, valuelist []interface{}, limit map[string]string) (map[string]string, error)
*
- 使用db prepare方式查询单条数据
- @param dbName
- @param title 查询的字段名
- @param where 查询条件
- @param valuelist 查询的条件值
- @param limit 查询排序
- GZ
- 2020/05/19
func GetDbTableName ¶
func GetJoinListByStmt ¶
func GetJoinListByStmt(dbName string, tableA, tableA_alias string, tableB, tableB_alias string, join_type, join_on string, title string, where []string, valuelist []interface{}, limit map[string]string, page ...int) ([]map[string]string, error)
*
- 联表查询
- @param dbName
- @param tableA 表一
- @param tableA_alias 表一别名
- @param tableB 表二
- @param tableB_alias 表二别名
- @param join 联表方式
- @param join_on 联表字段
- @param title 查询的字段名
- @param where 查询条件
- @param valuelist 查询的条件值
- @param limit 查询排序
- @param page 查询范围,可传两个值 pageNum,pageSize
- GZ
- 2020/11/23
func GetList ¶
func GetList(dbName, table string, title string, where map[string]string, limit map[string]string) ([]map[string]string, error)
*
- 查询列表
- 2018/04/19
func GetListByStmt ¶
func GetListByStmt(dbName string, table string, title string, where []string, valuelist []interface{}, limit map[string]string, page ...int) ([]map[string]string, error)
*
- 使用db prepare方式查询列表
- @param dbName
- @param title 查询的字段名
- @param where 查询条件
- @param valuelist 查询的条件值
- @param limit 查询排序
- @param page 查询范围,可传两个值 pageNum,pageSize
- GZ
- 2020/05/19
func InsertByStmt ¶
func InsertByStmt(dbName string, table string, data []string, valuelist []interface{}) (int64, error)
*
- 使用db prepare写入数据
- @param dbName
- @param table 表名
- @param data 写入的字段
- @param valuelist 写入的值
- GZ
- 2020/08/06
func LeftJoinListByStmt ¶ added in v0.6.7
func LeftJoinListByStmt(dbName string, tableA, tableB string, join_on string, title string, where []string, valuelist []interface{}, limit map[string]string, page ...int) ([]map[string]string, error)
*
- 左联表查询
- @param dbName
- @param tableA 表一
- @param tableB 表二
- @param join_on 联表字段
- @param title 查询的字段名
- @param where 查询条件
- @param valuelist 查询的条件值
- @param limit 查询排序
- @param page 查询范围,可传两个值 pageNum,pageSize
- GZ
- 2021/1/27
func StmtForRead ¶
func StmtForRead(dbName, table string, title string, where []string, limit map[string]string) (*sql.Stmt, error)
*
- 准备查询
- return Stmt error
func TxDelete ¶
func TxDelete(tx *sql.Tx, dbname, table string, where map[string]string, del_count ...string) (int64, error)
*
- 删除数据
- @param count 删除数量
func TxGetData ¶
func TxGetData(tx *sql.Tx, dbName string, table string, title string, where []string, valuelist []interface{}) (map[string]string, error)
*
- 使用db prepare方式查询单条数据
- @param dbName
- @param title 查询的字段名
- @param where 查询条件
- @param valuelist 查询的条件值
- @param limit 查询排序
- GZ
- 2020/05/19
func TxPreUpdate ¶
func TxPreUpdate(tx *sql.Tx, dbname, table string, data []string, where []string, valuelist []interface{}) (int64, error)
*
- 准备更新
- return Stmt error
func TxUpdate ¶
func TxUpdate(tx *sql.Tx, dbname, table string, data map[string]string, where map[string]string) (int64, error)
*
- 修改数据
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.