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.
63 64 65 66 |
# File 'lib/card/query.rb', line 63 def initialize @fields, @joins, @conditions = [],[],[],[] @tables, @group, @order, @limit, @offset = "","","","","" end |
Instance Attribute Details
#conditions ⇒ Object
Returns the value of attribute conditions.
61 62 63 |
# File 'lib/card/query.rb', line 61 def conditions @conditions end |
#fields ⇒ Object
Returns the value of attribute fields.
61 62 63 |
# File 'lib/card/query.rb', line 61 def fields @fields end |
#group ⇒ Object
Returns the value of attribute group.
61 62 63 |
# File 'lib/card/query.rb', line 61 def group @group end |
#joins ⇒ Object
Returns the value of attribute joins.
61 62 63 |
# File 'lib/card/query.rb', line 61 def joins @joins end |
#limit ⇒ Object
Returns the value of attribute limit.
61 62 63 |
# File 'lib/card/query.rb', line 61 def limit @limit end |
#offset ⇒ Object
Returns the value of attribute offset.
61 62 63 |
# File 'lib/card/query.rb', line 61 def offset @offset end |
#order ⇒ Object
Returns the value of attribute order.
61 62 63 |
# File 'lib/card/query.rb', line 61 def order @order end |
#tables ⇒ Object
Returns the value of attribute tables.
61 62 63 |
# File 'lib/card/query.rb', line 61 def tables @tables end |
Instance Method Details
#to_s ⇒ Object
68 69 70 71 72 73 |
# File 'lib/card/query.rb', line 68 def to_s "( select #{fields.reject(&:blank?).join(', ')} from #{tables} #{joins.join(' ')} where #{conditions.reject(&:blank?).join(' and ')} #{group} #{order} #{limit} #{offset} )" end |