gdb链式操作使用方式简单灵活,是GF框架官方推荐的数据库操作方式。链式操作可以通过数据库对象的db.Table/db.Model方法或者事务对象的tx.Table/tx.Model方法,基于指定的数据表返回一个链式操作对象*Model,该对象可以执行以下方法。

    接口文档: https://godoc.org/github.com/gogf/gf/database/gdb#Model

    1. func (m *Model) Insert(data ...interface{}) (result sql.Result, err error)
    2. func (m *Model) Replace(data ...interface{}) (result sql.Result, err error)
    3. func (m *Model) Save(data ...interface{}) (result sql.Result, err error)
    4. func (m *Model) Update(dataAndWhere ...interface{}) (result sql.Result, err error)
    5. func (m *Model) Delete(where ...interface{}) (result sql.Result, err error)
    6. func (m *Model) All(where ...interface{} (Result, error)
    7. func (m *Model) One(where ...interface{}) (Record, error)
    8. func (m *Model) Array(fieldsAndWhere ...interface{}) ([]Value, error)
    9. func (m *Model) Value(fieldsAndWhere ...interface{}) (Value, error)
    10. func (m *Model) Count(where ...interface{}) (int, error)
    11. func (m *Model) FindAll(where ...interface{}) (Result, error)
    12. func (m *Model) FindOne(where ...interface{}) (Record, error)
    13. func (m *Model) FindArray(fieldsAndWhere ...interface{}) (Value, error)
    14. func (m *Model) FindValue(fieldsAndWhere ...interface{}) (Value, error)
    15. func (m *Model) FindCount(where ...interface{}) (int, error)
    16. func (m *Model) Struct(pointer interface{}) error
    17. func (m *Model) Structs(pointer interface{}) error
    18. func (m *Model) Scan(pointer interface{}) error
    19. func (m *Model) LeftJoin(table ...string) *Model
    20. func (m *Model) RightJoin(table ...string) *Model
    21. func (m *Model) InnerJoin(table ...string) *Model
    22. func (m *Model) Where(where interface{}, args...interface{}) *Model
    23. func (m *Model) WherePri(where interface{}, args ...interface{}) *Model
    24. func (m *Model) And(where interface{}, args ...interface{}) *Model
    25. func (m *Model) Or(where interface{}, args ...interface{}) *Model
    26. func (m *Model) Group(group string) *Model
    27. func (m *Model) Order(order string) *Model
    28. func (m *Model) Fields(fields string) *Model
    29. func (m *Model) FieldsEx(fields string) *Model
    30. func (m *Model) Data(data...interface{}) *Model
    31. func (m *Model) Batch(batch int) *Model
    32. func (m *Model) Filter() *Model
    33. func (m *Model) Safe(safe...bool) *Model
    34. func (m *Model) DB(db DB) *Model
    35. func (m *Model) TX(tx *TX) *Model
    36. func (m *Model) Master() *Model
    37. func (m *Model) Slave() *Model
    38. func (m *Model) As(as string) *Model
    39. func (m *Model) Chunk(limit int, callback func(result Result, err error) bool)
    40. func (m *Model) Schema(schema string) *Model
    41. func (m *Model) Option(option int) *Model
    42. func (m *Model) OmitEmpty() *Model
    43. func (m *Model) Page(page, limit int) (*Model)
    44. func (m *Model) Offset(offset int) *Model
    45. func (m *Model) Limit(start int, limit int) *Model