session_cond.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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/go-xorm/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. //
  9. // Deprecated: use SQL instead.
  10. func (session *Session) Sql(query string, args ...interface{}) *Session {
  11. return session.SQL(query, args...)
  12. }
  13. // SQL provides raw sql input parameter. When you have a complex SQL statement
  14. // and cannot use Where, Id, In and etc. Methods to describe, you can use SQL.
  15. func (session *Session) SQL(query interface{}, args ...interface{}) *Session {
  16. session.Statement.SQL(query, args...)
  17. return session
  18. }
  19. // Where provides custom query condition.
  20. func (session *Session) Where(query interface{}, args ...interface{}) *Session {
  21. session.Statement.Where(query, args...)
  22. return session
  23. }
  24. // And provides custom query condition.
  25. func (session *Session) And(query interface{}, args ...interface{}) *Session {
  26. session.Statement.And(query, args...)
  27. return session
  28. }
  29. // Or provides custom query condition.
  30. func (session *Session) Or(query interface{}, args ...interface{}) *Session {
  31. session.Statement.Or(query, args...)
  32. return session
  33. }
  34. // Id provides converting id as a query condition
  35. //
  36. // Deprecated: use ID instead
  37. func (session *Session) Id(id interface{}) *Session {
  38. return session.ID(id)
  39. }
  40. // ID provides converting id as a query condition
  41. func (session *Session) ID(id interface{}) *Session {
  42. session.Statement.ID(id)
  43. return session
  44. }
  45. // In provides a query string like "id in (1, 2, 3)"
  46. func (session *Session) In(column string, args ...interface{}) *Session {
  47. session.Statement.In(column, args...)
  48. return session
  49. }
  50. // NotIn provides a query string like "id in (1, 2, 3)"
  51. func (session *Session) NotIn(column string, args ...interface{}) *Session {
  52. session.Statement.NotIn(column, args...)
  53. return session
  54. }
  55. // Conds returns session query conditions
  56. func (session *Session) Conds() builder.Cond {
  57. return session.Statement.cond
  58. }