Module: Ronin::SQL::Statements

Included in:
Clause, InjectionExpr, StatementList
Defined in:
lib/ronin/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:



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

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:



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

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

#insert(&block) ⇒ Statement

Creates a new INSERT statement.

Returns:



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

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:



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

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:



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

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:



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

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