Module: Ronin::Code::SQL::Statements

Included in:
Clause, InjectionExpr, StatementList
Defined in:
lib/ronin/code/sql/statements.rb

Overview

Methods for creating common SQL Statements.

Instance Method Summary collapse

Instance Method Details

#delete(table, &block) ⇒ Statement

Creates a new DELETE statement.

Parameters:

  • table (Field, Symbol)

    The table to delete from.

Returns:



98
99
100
# File 'lib/ronin/code/sql/statements.rb', line 98

def delete(table,&block)
  statement([:DELETE, :FROM],table,&block)
end

#drop_table(table, &block) ⇒ Statement

Creates a new DROP TABLE statement.

Parameters:

  • table (Field, Symbol)

    The table to drop.

Returns:



111
112
113
# File 'lib/ronin/code/sql/statements.rb', line 111

def drop_table(table,&block)
  statement([:DROP, :TABLE],table,&block)
end

#insert(&block) ⇒ Statement

Creates a new INSERT statement.

Returns:



72
73
74
# File 'lib/ronin/code/sql/statements.rb', line 72

def insert(&block)
  statement(:INSERT,&block)
end

#select(*columns, &block) ⇒ Statement

Creates a new SELECT statement.

Parameters:

  • columns (Array<Field, Symbol>)

    The columns to select.

Returns:



62
63
64
# File 'lib/ronin/code/sql/statements.rb', line 62

def select(*columns,&block)
  statement(:SELECT,columns,&block)
end

#statement(keyword, argument = nil) {|(statement)| ... } ⇒ Statement

Creates an arbitrary statement.

Parameters:

  • keyword (Symbol)

    Name of the statement.

  • argument (Object) (defaults to: nil)

    Additional argument for the statement.

Yields:

  • ((statement))

    If a block is given, it will be called.

Yield Parameters:

  • statement (Statement)

    If the block accepts an argument, it will be passed the new statement. Otherwise the block will be evaluated within the statement.

Returns:



49
50
51
# File 'lib/ronin/code/sql/statements.rb', line 49

def statement(keyword,argument=nil,&block)
  Statement.new(keyword,argument,&block)
end

#update(table, &block) ⇒ Statement

Creates a new UPDATE statement.

Parameters:

  • table (Field, Symbol)

    The table to update.

Returns:



85
86
87
# File 'lib/ronin/code/sql/statements.rb', line 85

def update(table,&block)
  statement(:UPDATE,table,&block)
end