Documentation ¶
Index ¶
- Variables
- func CloseConn() error
- func CloseSlaverConn() error
- func CloseStmt(stmt *sql.Stmt) error
- func Connect(DBHOST, DBUSER, DBPWD, DBNAME, DBPORT string, conns ...int) (bool, error)
- func ConnectSlaver(DBHOST, DBUSER_SLAVER, DBPWD_SLAVER, DBNAME, DBPORT string, conns ...int) (bool, error)
- func GetDataByStmt(dbName string, table string, title string, where []string, ...) (map[string]string, error)
- func GetDbTableName(dbName, table string) string
- func GetJoinListByStmt(dbName string, tableA, tableA_alias string, tableB, tableB_alias string, ...) ([]map[string]string, error)
- func GetListByStmt(dbName string, table string, title string, where []string, ...) ([]map[string]string, error)
- func GetPage(pageNum, pageSize interface{}) (string, string)
- 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 SetTablePrefix(pre string)
- 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 StrFirstToUpper(str string) string
- func StringJoin(s ...string) string
- func ToInt(inter interface{}) int
- func ToInt64(inter interface{}) int64
- func ToStr(v interface{}) string
- func ToString(v interface{}) string
- func UpdateByStmt(dbName string, table string, data []string, where []string, ...) (int64, error)
- type Query
- func (this *Query) Alias(tablename string) *Query
- func (this *Query) BuildSelectSql() (map[string]interface{}, error)
- func (this *Query) Clean() *Query
- func (this *Query) Conn(conn *sql.DB) *Query
- func (this *Query) Create() (int64, error)
- func (this *Query) CreateAll() (int64, error)
- func (this *Query) CreateAllStmt() error
- func (this *Query) CreateStmt() error
- func (this *Query) Data(data string) *Query
- func (this *Query) Datas(datas []string) *Query
- func (this *Query) Db(dbname string) *Query
- func (this *Query) Debug(debug bool) *Query
- func (this *Query) Delete() (int64, error)
- func (this *Query) DeleteStmt() error
- func (this *Query) Find() (map[string]string, error)
- func (this *Query) Get() (map[string]string, error)
- func (this *Query) GetTableInfo(table string) (map[string]interface{}, error)
- func (this *Query) GetTableName(table string) string
- func (this *Query) Groupby(groupby string) *Query
- func (this *Query) Having(having string) *Query
- func (this *Query) Join(join []string) *Query
- func (this *Query) LeftJoin(table_name string, condition string, table_alias ...string) *Query
- func (this *Query) List() ([]map[string]string, error)
- func (this *Query) Orderby(orderby string) *Query
- func (this *Query) Page(page int) *Query
- func (this *Query) PageSize(page_num int) *Query
- func (this *Query) QueryStmt() error
- func (this *Query) RightJoin(table_name string, condition string, table_alias ...string) *Query
- func (this *Query) SaveData(value map[string]interface{}) *Query
- func (this *Query) SaveDatas(value []map[string]interface{}) *Query
- func (this *Query) Select() ([]map[string]string, error)
- func (this *Query) Table(tablename string) *Query
- func (this *Query) Title(title string) *Query
- func (this *Query) UpdField(value string) *Query
- func (this *Query) UpdFields(value []string) *Query
- func (this *Query) Update() (int64, error)
- func (this *Query) UpdateAll() (int64, error)
- func (this *Query) UpdateAllStmt() error
- func (this *Query) UpdateStmt() error
- func (this *Query) Value(value interface{}) *Query
- func (this *Query) Values(values []interface{}) *Query
- func (this *Query) Where(where string) *Query
- func (this *Query) WhereOr(where string) *Query
- func (this *Query) Wheres(wheres []string) *Query
- type TxQuery
- func (this *TxQuery) Alias(tablename string) *TxQuery
- func (this *TxQuery) BuildSelectSql() (map[string]interface{}, error)
- func (this *TxQuery) Clean() *TxQuery
- func (this *TxQuery) Commit() error
- func (this *TxQuery) Conn(conn *sql.DB) *TxQuery
- func (this *TxQuery) Create() (int64, error)
- func (this *TxQuery) CreateAll() (int64, error)
- func (this *TxQuery) CreateAllStmt() error
- func (this *TxQuery) CreateStmt() error
- func (this *TxQuery) Data(data string) *TxQuery
- func (this *TxQuery) Datas(datas []string) *TxQuery
- func (this *TxQuery) Db(dbname string) *TxQuery
- func (this *TxQuery) Debug(debug bool) *TxQuery
- func (this *TxQuery) Delete() (int64, error)
- func (this *TxQuery) DeleteStmt() error
- func (this *TxQuery) Find() (map[string]string, error)
- func (this *TxQuery) GetTableInfo(table string) (map[string]interface{}, error)
- func (this *TxQuery) GetTableName(table string) string
- func (this *TxQuery) Groupby(groupby string) *TxQuery
- func (this *TxQuery) Having(having string) *TxQuery
- func (this *TxQuery) Join(join []string) *TxQuery
- func (this *TxQuery) LeftJoin(table_name string, condition string, table_alias ...string) *TxQuery
- func (this *TxQuery) Orderby(orderby string) *TxQuery
- func (this *TxQuery) Page(page int) *TxQuery
- func (this *TxQuery) PageSize(page_num int) *TxQuery
- func (this *TxQuery) QueryStmt() error
- func (this *TxQuery) RightJoin(table_name string, condition string, table_alias ...string) *TxQuery
- func (this *TxQuery) Rollback() error
- func (this *TxQuery) SaveData(value map[string]interface{}) *TxQuery
- func (this *TxQuery) SaveDatas(value []map[string]interface{}) *TxQuery
- func (this *TxQuery) Select() ([]map[string]string, error)
- func (this *TxQuery) Table(tablename string) *TxQuery
- func (this *TxQuery) Title(title string) *TxQuery
- func (this *TxQuery) UpdField(value string) *TxQuery
- func (this *TxQuery) UpdFields(value []string) *TxQuery
- func (this *TxQuery) Update() (int64, error)
- func (this *TxQuery) UpdateAll() (int64, error)
- func (this *TxQuery) UpdateAllStmt() error
- func (this *TxQuery) UpdateStmt() error
- func (this *TxQuery) Value(value interface{}) *TxQuery
- func (this *TxQuery) Values(values []interface{}) *TxQuery
- func (this *TxQuery) Where(where string) *TxQuery
- func (this *TxQuery) WhereOr(where string) *TxQuery
- func (this *TxQuery) Wheres(wheres []string) *TxQuery
Constants ¶
This section is empty.
Variables ¶
View Source
var DB *sql.DB
主库
View Source
var DB_PROVIDER string
db类型,默认空,如TencentDB(腾讯),
View Source
var SLAVER_DB *sql.DB
从库
View Source
var TABLE_PREFIX string
表前缀
Functions ¶
func CloseSlaverConn ¶
func CloseSlaverConn() error
func ConnectSlaver ¶
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 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 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 ¶
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 SetTablePrefix ¶
func SetTablePrefix(pre string)
func StmtForRead ¶
func StmtForRead(dbName, table string, title string, where []string, limit map[string]string) (*sql.Stmt, error)
*
- 准备查询
- return Stmt error
Types ¶
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
func (*Query) BuildSelectSql ¶
构造子查询
func (*Query) GetTableInfo ¶
获取表格信息
type TxQuery ¶
type TxQuery struct {
// contains filtered or unexported fields
}
func NewTxQuery ¶
func NewTxQuery() *TxQuery
func (*TxQuery) BuildSelectSql ¶
构造子查询
func (*TxQuery) GetTableInfo ¶
获取表格信息
Click to show internal directories.
Click to hide internal directories.