class PGresult
Constants
- BAD_RESPONSE
- COMMAND_OK
- COPY_IN
- COPY_OUT
- EMPTY_QUERY
- FATAL_ERROR
- NONFATAL_ERROR
- TUPLES_OK
Attributes
fields[R]
TODO: status, getlength, cmdstatus
result[R]
TODO: status, getlength, cmdstatus
Public Class Methods
new(res)
click to toggle source
# File lib/postgres-pr/postgres-compat.rb, line 80 def initialize(res) @res = res @fields = @res.fields.map {|f| f.name} @result = @res.rows end
Public Instance Methods
[](index)
click to toggle source
# File lib/postgres-pr/postgres-compat.rb, line 76 def [](index) @result[index] end
clear()
click to toggle source
free the result set
# File lib/postgres-pr/postgres-compat.rb, line 134 def clear @res = @fields = @result = nil end
cmdstatus()
click to toggle source
# File lib/postgres-pr/postgres-compat.rb, line 129 def cmdstatus @res.cmd_tag || '' end
cmdtuples()
click to toggle source
Returns the number of rows affected by the SQL command
# File lib/postgres-pr/postgres-compat.rb, line 139 def cmdtuples case @res.cmd_tag when nil return nil when /^INSERT\s+(\d+)\s+(\d+)$/, /^(DELETE|UPDATE|MOVE|FETCH)\s+(\d+)$/ $2.to_i else nil end end
each(&block)
click to toggle source
# File lib/postgres-pr/postgres-compat.rb, line 72 def each(&block) @result.each(&block) end
fieldname(index)
click to toggle source
# File lib/postgres-pr/postgres-compat.rb, line 98 def fieldname(index) @fields[index] end
fieldnum(name)
click to toggle source
# File lib/postgres-pr/postgres-compat.rb, line 102 def fieldnum(name) @fields.index(name) end
getvalue(tup_num, field_num)
click to toggle source
# File lib/postgres-pr/postgres-compat.rb, line 117 def getvalue(tup_num, field_num) @result[tup_num][field_num] end
num_fields()
click to toggle source
# File lib/postgres-pr/postgres-compat.rb, line 94 def num_fields @fields.size end
num_tuples()
click to toggle source
# File lib/postgres-pr/postgres-compat.rb, line 90 def num_tuples @result.size end
size(index)
click to toggle source
# File lib/postgres-pr/postgres-compat.rb, line 111 def size(index) raise PGError, 'size not implemented' # TODO: correct? @res.fields[index].typlen end
status()
click to toggle source
# File lib/postgres-pr/postgres-compat.rb, line 121 def status if num_tuples > 0 TUPLES_OK else COMMAND_OK end end
type(index)
click to toggle source
# File lib/postgres-pr/postgres-compat.rb, line 106 def type(index) # TODO: correct? @res.fields[index].type_oid end