Class: Card::Query::SqlStatement
Instance Attribute Summary collapse
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#group ⇒ Object
Returns the value of attribute group.
-
#joins ⇒ Object
Returns the value of attribute joins.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#order ⇒ Object
Returns the value of attribute order.
-
#tables ⇒ Object
Returns the value of attribute tables.
Instance Method Summary collapse
-
#initialize ⇒ SqlStatement
constructor
A new instance of SqlStatement.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ SqlStatement
Returns a new instance of SqlStatement.
64 65 66 67 |
# File 'lib/card/query.rb', line 64 def initialize @fields, @joins, @conditions = [],[],[],[] @tables, @group, @order, @limit, @offset = "","","","","" end |
Instance Attribute Details
#conditions ⇒ Object
Returns the value of attribute conditions.
62 63 64 |
# File 'lib/card/query.rb', line 62 def conditions @conditions end |
#fields ⇒ Object
Returns the value of attribute fields.
62 63 64 |
# File 'lib/card/query.rb', line 62 def fields @fields end |
#group ⇒ Object
Returns the value of attribute group.
62 63 64 |
# File 'lib/card/query.rb', line 62 def group @group end |
#joins ⇒ Object
Returns the value of attribute joins.
62 63 64 |
# File 'lib/card/query.rb', line 62 def joins @joins end |
#limit ⇒ Object
Returns the value of attribute limit.
62 63 64 |
# File 'lib/card/query.rb', line 62 def limit @limit end |
#offset ⇒ Object
Returns the value of attribute offset.
62 63 64 |
# File 'lib/card/query.rb', line 62 def offset @offset end |
#order ⇒ Object
Returns the value of attribute order.
62 63 64 |
# File 'lib/card/query.rb', line 62 def order @order end |
#tables ⇒ Object
Returns the value of attribute tables.
62 63 64 |
# File 'lib/card/query.rb', line 62 def tables @tables end |
Instance Method Details
#to_s ⇒ Object
69 70 71 72 73 |
# File 'lib/card/query.rb', line 69 def to_s select = fields.reject(&:blank?) * ', ' where = conditions.reject(&:blank?) * ' and ' ['(SELECT', select, 'FROM', tables, joins, 'WHERE', where, group, order, limit, offset, ')'].compact * ' ' end |