Documentation ¶
Index ¶
- func Get(dest interface{}, query string, args ...interface{}) error
- func GetDB() *sqlx.DB
- func GetPlaceholderByFields(fields string) string
- func GetPlaceholderN(n int) string
- func Init(cfg Config) (err error)
- func Insert(sql string, args ...interface{}) (int, error)
- func IsNoRowsErr(err error) bool
- type Config
- type PageHelper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPlaceholderByFields ¶
func GetPlaceholderN ¶
func IsNoRowsErr ¶
Types ¶
type Config ¶
type Config struct { Addr string Port int User string Passwd string DBName string CharSet string DialTimeout string // I/O read timeout. The value must be a decimal number with a unit suffix ("ms", "s", "m", "h"), such as "30s", "0.5m" or "1m30s". default:0 不超时 ReadTimeout string // I/O write timeout. The value must be a decimal number with a unit suffix ("ms", "s", "m", "h"), such as "30s", "0.5m" or "1m30s". default:0 即不超时 WriteTimeout string }
type PageHelper ¶
type PageHelper struct {
// contains filtered or unexported fields
}
PageHelper 目的是做一些通用的限制, 如:
- 参数校验
- limit参数生成
func NewPageHelper ¶
func NewPageHelper(po, ps int) *PageHelper
func (*PageHelper) FromTo ¶
func (p *PageHelper) FromTo() (x, y int)
FromTo 返回数据位置 [x, y] 注意 左右都是闭区间
func (*PageHelper) GetLimitParams ¶
func (p *PageHelper) GetLimitParams() (x int, y int)
GetLimitParams 返回sql中limit x, y
func (*PageHelper) GetTotal ¶
func (p *PageHelper) GetTotal() int
func (*PageHelper) HasNext ¶
func (p *PageHelper) HasNext() bool
func (*PageHelper) SetOffset ¶
func (p *PageHelper) SetOffset(off int)
SetOffset 设置额外起点 例如:共81条数据,获取 第3页(每页10条)时
offset = 0,则sql的limit为 20, 10 offset = 5,则sql的limit为 25, 10
func (*PageHelper) SetTotal ¶
func (p *PageHelper) SetTotal(total int)
Click to show internal directories.
Click to hide internal directories.