Class: Swift::Statement

Inherits:
Object
  • Object
show all
Defined in:
lib/swift/statement.rb

Overview

Statement.

Wrapper for server side prepared statements.

Instance Method Summary collapse

Constructor Details

#initialize(record, command) ⇒ Statement

Returns a new instance of Statement.



8
9
10
11
# File 'lib/swift/statement.rb', line 8

def initialize record, command
  @record    = record
  @statement = Swift.db.prepare(command)
end

Instance Method Details

#execute(*bind, &block) ⇒ Swift::Result

Execute a statement.

Examples:

statement = Swift.db.prepare(User, "select * from users where id > ?")
statement.execute(10)

Parameters:

  • bind (*Object)

    Bind values

Returns:



21
22
23
# File 'lib/swift/statement.rb', line 21

def execute *bind, &block
  Result.new(@record, @statement.execute(*bind), &block)
end