Documentation ¶
Index ¶
- Constants
- Variables
- func CamelCase(str string) string
- func CreateOrmModels(dbmaster, dbslaver, gdir string)
- func FileExists(path string) bool
- func GetMCache() cache.Cacher
- func LoadDbConfig(confPtr interface{})
- func NewEngine(skey string) *sqlx.DB
- func NewMysql() *mysqlSt
- func SetDBCache(c cache.Cacher)
- func SliceSqlMap2Struct(ptrSt interface{}, data []SqlMap) error
- func SnakeCase(str string) string
- func SqlMap2Struct(ptrSt interface{}, data SqlMap) error
- func SqlMapDeleteItems(a SqlMap, keys ...string)
- type DHandler
- type DbConfig
- type ModelSt
- func (self *ModelSt) CacheKey(ckey string) string
- func (self *ModelSt) Delete(id interface{}) int64
- func (self *ModelSt) EqMod(idx, oidx int64) bool
- func (self *ModelSt) GetAsMap(offset, limit int64, cHandler WHandler, fields string) SqlMap
- func (self *ModelSt) GetAsSQL(sql string, isFirst bool, offset, limit int64) interface{}
- func (self *ModelSt) GetCacheVer() int64
- func (self *ModelSt) GetColumn(offset, limit int64, cHandler WHandler, fields string, args ...string) []string
- func (self *ModelSt) GetHash(args ...interface{}) string
- func (self *ModelSt) GetItem(cHandler WHandler, fields string, args ...string) SqlMap
- func (self *ModelSt) GetList(offset, limit int64, cHandler WHandler, fields string, args ...string) []SqlMap
- func (self *ModelSt) GetNameMap(offset, limit int64, cHandler WHandler, fields string, key string) map[string]SqlMap
- func (self *ModelSt) GetOne(id interface{}) SqlMap
- func (self *ModelSt) GetSlot() int
- func (self *ModelSt) GetTable() string
- func (self *ModelSt) GetTotal(cHandler WHandler, fields string) string
- func (self *ModelSt) IdClearCache(id interface{}) *ModelSt
- func (self *ModelSt) Init(data map[string]interface{}, fields map[string]reflect.Kind)
- func (self *ModelSt) MultiDelete(whandler WHandler) int64
- func (self *ModelSt) MultiUpdate(whandler WHandler, vhandler VHandler) int64
- func (self *ModelSt) NewOne(fields map[string]interface{}, dupfields map[string]interface{}) int64
- func (self *ModelSt) NewOneFromHandler(vhandler VHandler, dhandler DHandler) int64
- func (self *ModelSt) Query() *QuerySt
- func (self *ModelSt) ResetTable() *ModelSt
- func (self *ModelSt) Save(id interface{}, fields map[string]interface{}) int64
- func (self *ModelSt) SaveFromHandler(id interface{}, vhandler VHandler) int64
- func (self *ModelSt) SetCacheVer()
- func (self *ModelSt) SetDevTable(idx int64) *ModelSt
- func (self *ModelSt) SetModTable(idx int64) *ModelSt
- func (self *ModelSt) SetYmTable(format string) *ModelSt
- type QuerySt
- func (q QuerySt) AsSql(mode string) string
- func (q QuerySt) Clear(parts ...string) *mysqlSt
- func (q *QuerySt) Delete() int64
- func (q QuerySt) Duplicate(field string, value interface{}, args ...string) *mysqlSt
- func (q QuerySt) Field(fields string) *mysqlSt
- func (q *QuerySt) GetAsSql(sql string, isFirst bool, offset, limit int64) []SqlMap
- func (q *QuerySt) GetColumn(offset, limit int64) []string
- func (q *QuerySt) GetDb() *sqlx.DB
- func (q *QuerySt) GetList(offset, limit int64) []SqlMap
- func (q *QuerySt) GetMap(offset, limit int64) SqlMap
- func (q *QuerySt) GetRow() SqlMap
- func (q *QuerySt) GetValue() string
- func (q QuerySt) GetWheres() string
- func (q QuerySt) GroupBy(fields ...string) *mysqlSt
- func (q QuerySt) Having(having string) *mysqlSt
- func (q *QuerySt) Insert(fields map[string]interface{}, isReplace bool) int64
- func (q *QuerySt) NameMap(key string, offset, limit int64) map[string]SqlMap
- func (q QuerySt) OrderBy(field, dir string) *mysqlSt
- func (q QuerySt) Reset() *mysqlSt
- func (q QuerySt) SetIsReplace(isReplace bool) *mysqlSt
- func (q QuerySt) Table(table ...string) *mysqlSt
- func (q *QuerySt) Update(fields map[string]interface{}) int64
- func (q QuerySt) Value(field string, value interface{}, args ...string) *mysqlSt
- func (q QuerySt) Where(field string, value interface{}, args ...string) *mysqlSt
- type SqlMap
- type VHandler
- type WHandler
Constants ¶
View Source
const ( DT_SQL = "sql" DT_AUTO = "auto" OP_AS = "AS" OP_MAX = "MAX" OP_MIN = "MIN" OP_SUM = "SUM" OP_AVG = "AVG" OP_COUNT = "COUNT" OP_EQ = "=" OP_NE = "<>" OP_GT = ">" OP_LT = "<" OP_GE = ">=" OP_LE = "<=" OP_BETWEEN = "BETWEEN" OP_NOTBETWEEN = "NOT BETWEEN" OP_LIKE = "LIKE" OP_NOTLIKE = "NOT LIKE" OP_REGEXP = "REGEXP" OP_ISNULL = "IS NULL" OP_ISNOTNULL = "IS NOT NULL" OP_IN = "IN" OP_NOTIN = "NOT IN" OP_AND = "AND" OP_OR = "OR" OP_NOT = "NOT" OP_SQL = "SQL" ASC = "ASC" DESC = "DESC" )
View Source
const (
DBVERCKEY = "dbver"
)
Variables ¶
View Source
var ( IsShowSql = true GdbConfig = make(map[string]*DbConfig) )
View Source
var GdbCache cache.Cacher = nil
View Source
var GmCache cache.Cacher = nil
View Source
var Gmodelstpl = `` /* 449-byte string literal not displayed */
Functions ¶
func LoadDbConfig ¶
func LoadDbConfig(confPtr interface{})
*
- 数据库的配置 通过配置导入,配置必须传结构体指针 示例
- @confPtr *Config 配置对象的指针变量
type Config struct { ... Redis cache.RedisConfig `yaml:"redis"` DbMaster DbConfig `yaml:"dbmaster"` DbSlaver DbConfig `yaml:"dbslaver"` }
func SliceSqlMap2Struct ¶
提供SqlMap转义成struct结构类型 只支持常用类型的
func SqlMap2Struct ¶
提供SqlMap转义成struct结构类型 只支持常用类型的
Types ¶
type DbConfig ¶
type DbConfig struct { Driver string `yaml:"driver"` Host string `yaml:"host"` MaxOpenConns int `yaml:"maxOpenConns"` MaxIdleConns int `yaml:"maxIdleConns"` }
*****************************************************************************
数据库的适配器,主要调整数据库与配置类 Redis与配置类的衔接,初始化数据库缓存 *****************************************************************************
type ModelSt ¶
type ModelSt struct {
// contains filtered or unexported fields
}
定义数据模型的基础结构
func (*ModelSt) GetColumn ¶
func (self *ModelSt) GetColumn(offset, limit int64, cHandler WHandler, fields string, args ...string) []string
只获取数据信息列表
func (*ModelSt) GetList ¶
func (self *ModelSt) GetList(offset, limit int64, cHandler WHandler, fields string, args ...string) []SqlMap
只获取数据信息列表
func (*ModelSt) GetNameMap ¶
func (self *ModelSt) GetNameMap(offset, limit int64, cHandler WHandler, fields string, key string) map[string]SqlMap
获取命名map,key必须属于fields当中的字段
func (*ModelSt) IdClearCache ¶
根据ID删除缓存策略
func (*ModelSt) MultiDelete ¶
删除多条记录 单数缓存数据可能还是存在 通过id获取数据的情况
func (*ModelSt) MultiUpdate ¶
通过执行匿名函数实现数据更新关系绑定
func (*ModelSt) NewOneFromHandler ¶
通过执行匿名函数实现数据更新关系绑定
func (*ModelSt) ResetTable ¶
func (*ModelSt) SaveFromHandler ¶
通过执行匿名函数实现数据更新关系绑定
func (*ModelSt) SetDevTable ¶
func (*ModelSt) SetModTable ¶
func (*ModelSt) SetYmTable ¶
这个时间格式填写golang诞辰 2006-01-02 15:04:05 等
type QuerySt ¶
type QuerySt struct {
// contains filtered or unexported fields
}
func (QuerySt) SetIsReplace ¶
func (q QuerySt) SetIsReplace(isReplace bool) *mysqlSt
设定插入的时候执行replace into
Click to show internal directories.
Click to hide internal directories.