session_cond.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2017 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package xorm
  5. import "github.com/2637309949/dolphin/packages/xormplus/builder"
  6. // SQL provides raw sql input parameter. When you have a complex SQL statement
  7. // and cannot use Where, Id, In and etc. Methods to describe, you can use SQL.
  8. func (session *Session) SQL(query interface{}, args ...interface{}) *Session {
  9. session.isSqlFunc = true
  10. session.statement.SQL(query, args...)
  11. return session
  12. }
  13. // Where provides custom query condition.
  14. func (session *Session) Where(query interface{}, args ...interface{}) *Session {
  15. session.statement.Where(query, args...)
  16. return session
  17. }
  18. // And provides custom query condition.
  19. func (session *Session) And(query interface{}, args ...interface{}) *Session {
  20. session.statement.And(query, args...)
  21. return session
  22. }
  23. // Or provides custom query condition.
  24. func (session *Session) Or(query interface{}, args ...interface{}) *Session {
  25. session.statement.Or(query, args...)
  26. return session
  27. }
  28. // ID provides converting id as a query condition
  29. func (session *Session) ID(id interface{}) *Session {
  30. session.statement.ID(id)
  31. return session
  32. }
  33. // In provides a query string like "id in (1, 2, 3)"
  34. func (session *Session) In(column string, args ...interface{}) *Session {
  35. session.statement.In(column, args...)
  36. return session
  37. }
  38. // NotIn provides a query string like "id in (1, 2, 3)"
  39. func (session *Session) NotIn(column string, args ...interface{}) *Session {
  40. session.statement.NotIn(column, args...)
  41. return session
  42. }
  43. // Conds returns session query conditions except auto bean conditions
  44. func (session *Session) Conds() builder.Cond {
  45. return session.statement.Conds()
  46. }