Class: Pgtk::Pool::Txn

Inherits:
Object
  • Object
show all
Defined in:
lib/pgtk/pool.rb

Overview

A temporary class to execute a single SQL request.

Instance Method Summary collapse

Constructor Details

#initialize(conn) ⇒ Txn

Returns a new instance of Txn.



121
122
123
# File 'lib/pgtk/pool.rb', line 121

def initialize(conn)
  @conn = conn
end

Instance Method Details

#exec(query, args = [], result = 0) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
# File 'lib/pgtk/pool.rb', line 125

def exec(query, args = [], result = 0)
  @conn.exec_params(query, args, result) do |res|
    if block_given?
      yield res
    else
      rows = []
      res.each { |r| rows << r }
      rows
    end
  end
end