Class: PGresult
- Inherits:
-
Object
- Object
- PGresult
- Includes:
- Enumerable
- Defined in:
- lib/postgres-pr/postgres-compat.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
TODO: status, getlength, cmdstatus.
-
#result ⇒ Object
readonly
TODO: status, getlength, cmdstatus.
Instance Method Summary collapse
- #[](index) ⇒ Object
-
#clear ⇒ Object
free the result set.
- #each(&block) ⇒ Object
- #fieldname(index) ⇒ Object
- #fieldnum(name) ⇒ Object
- #getvalue(tup_num, field_num) ⇒ Object
-
#initialize(res) ⇒ PGresult
constructor
A new instance of PGresult.
- #num_fields ⇒ Object
- #num_tuples ⇒ Object
- #size(index) ⇒ Object
- #type(index) ⇒ Object
Constructor Details
#initialize(res) ⇒ PGresult
Returns a new instance of PGresult.
51 52 53 54 55 |
# File 'lib/postgres-pr/postgres-compat.rb', line 51 def initialize(res) @res = res @fields = @res.fields.map {|f| f.name} @result = @res.rows end |
Instance Attribute Details
#fields ⇒ Object (readonly)
TODO: status, getlength, cmdstatus
59 60 61 |
# File 'lib/postgres-pr/postgres-compat.rb', line 59 def fields @fields end |
#result ⇒ Object (readonly)
TODO: status, getlength, cmdstatus
59 60 61 |
# File 'lib/postgres-pr/postgres-compat.rb', line 59 def result @result end |
Instance Method Details
#[](index) ⇒ Object
47 48 49 |
# File 'lib/postgres-pr/postgres-compat.rb', line 47 def [](index) @result[index] end |
#clear ⇒ Object
free the result set
94 95 96 |
# File 'lib/postgres-pr/postgres-compat.rb', line 94 def clear @res = @fields = @result = nil end |
#each(&block) ⇒ Object
43 44 45 |
# File 'lib/postgres-pr/postgres-compat.rb', line 43 def each(&block) @result.each(&block) end |
#fieldname(index) ⇒ Object
69 70 71 |
# File 'lib/postgres-pr/postgres-compat.rb', line 69 def fieldname(index) @fields[index] end |
#fieldnum(name) ⇒ Object
73 74 75 |
# File 'lib/postgres-pr/postgres-compat.rb', line 73 def fieldnum(name) @fields.index(name) end |
#getvalue(tup_num, field_num) ⇒ Object
89 90 91 |
# File 'lib/postgres-pr/postgres-compat.rb', line 89 def getvalue(tup_num, field_num) @result[tup_num][field_num] end |
#num_fields ⇒ Object
65 66 67 |
# File 'lib/postgres-pr/postgres-compat.rb', line 65 def num_fields @fields.size end |
#num_tuples ⇒ Object
61 62 63 |
# File 'lib/postgres-pr/postgres-compat.rb', line 61 def num_tuples @result.size end |
#size(index) ⇒ Object
83 84 85 86 87 |
# File 'lib/postgres-pr/postgres-compat.rb', line 83 def size(index) raise # TODO: correct? @res.fields[index].typlen end |
#type(index) ⇒ Object
77 78 79 80 81 |
# File 'lib/postgres-pr/postgres-compat.rb', line 77 def type(index) raise # TODO: correct? @res.fields[index].type_oid end |