Class SqlStatement
In: lib/sql_statement.rb
Parent: Object

Methods

Attributes

tables  [RW] 
to_sql  [R] 

Public Instance methods

Creates a new AndWhereBuilder instance, passing the block as a parameter, then executes to_sql on the AndWhereBuilder instance. The resulting string from the AndWhereBuilder instance is appended to the SQL statement. Returns self.

   Select[1].where { equal :column1, 1 }.and { equal :column2, 100 }.to_sql       #=> "select 1 where column1 = 1 and (column2 = 100)"

[Source]

    # File lib/sql_statement.rb, line 40
40:   def and(&block)
41:     @to_sql += AndWhereBuilder.new(self.tables, &block).to_sql
42:     self
43:   end

Creates a new AndWithOrConditionsWhereBuilder instance, passing the block as a parameter, then executes to_sql on the AndWithOrConditionsWhereBuilder instance. The resulting string from the AndWithOrConditionsWhereBuilder instance is appended to the SQL statement. Returns self.

   Select[1].where { equal :column1, 1 }.and_with_or_conditions { equal :column2, 100 }.to_sql
     #=> "select 1 where column1 = 1 and (column2 = 100)"

[Source]

    # File lib/sql_statement.rb, line 54
54:   def and_with_or_conditions(&block)
55:     @to_sql += AndWithOrConditionsWhereBuilder.new(self.tables, &block).to_sql
56:     self
57:   end

Creates a new OrWhereBuilder instance, passing the block as a parameter, then executes to_sql on the OrWhereBuilder instance. The resulting string from the OrWhereBuilder instance is appended to the SQL statement. Returns self.

   Select[1].where { equal :column1, 1 }.or { equal :column1, 100 }.to_sql       #=> "select 1 where column1 = 1 or (column1 = 100)"

[Source]

    # File lib/sql_statement.rb, line 28
28:   def or(&block)
29:     @to_sql += OrWhereBuilder.new(self.tables, &block).to_sql
30:     self
31:   end

Creates a new WhereBuilder instance, passing the block as a parameter, then executes to_sql on the WhereBuilder instance. The resulting string from the WhereBuilder instance is appended to the SQL statement. Returns self.

   Select[1].where { equal :column1, 1 }.to_sql       #=> "select 1 where column1 = 1"

[Source]

    # File lib/sql_statement.rb, line 16
16:   def where(&block)
17:     @to_sql += WhereBuilder.new(self.tables, &block).to_sql
18:     self
19:   end

[Validate]