Class: PGresult

### Home Classes Methods

### In Files

- lib/postgres-pr/pg-compat.rb
- lib/postgres-pr/postgres-compat.rb

### Parent

Object

### Methods

- ::new
- #[]
- #clear
- #cmd_tuples
- #cmdstatus
- #cmdtuples
- #each
- #fieldname
- #fieldnum
- #ftype
- #getvalue
- #nfields
- #ntuples
- #num_fields
- #num_tuples
- #size
- #status
- #type

### Included Modules

- Enumerable

### Class/Module Index

Quicksearch

- PostgresPR
- PostgresPR::Authentification
- PostgresPR::AuthentificationClearTextPassword
- PostgresPR::AuthentificationCryptPassword
- PostgresPR::AuthentificationKerberosV4
- PostgresPR::AuthentificationKerberosV5
- PostgresPR::AuthentificationMD5Password
- PostgresPR::AuthentificationOk
- PostgresPR::AuthentificationSCMCredential
- PostgresPR::BackendKeyData
- PostgresPR::CommandComplete
- PostgresPR::Connection
- PostgresPR::Connection::Result
- PostgresPR::CopyInResponse
- PostgresPR::CopyOutResponse
- PostgresPR::DataRow
- PostgresPR::DumpError
- PostgresPR::EmptyQueryResponse
- PostgresPR::ErrorResponse
- PostgresPR::Message
- PostgresPR::NoticeErrorMixin
- PostgresPR::NoticeResponse
- PostgresPR::ParameterStatus
- PostgresPR::Parse
- PostgresPR::ParseComplete
- PostgresPR::ParseError
- PostgresPR::PasswordMessage
- PostgresPR::Query
- PostgresPR::ReadyForQuery
- PostgresPR::RowDescription
- PostgresPR::RowDescription::FieldInfo
- PostgresPR::SSLRequest
- PostgresPR::SaltedAuthentificationMixin
- PostgresPR::StartupMessage
- PostgresPR::Terminate
- PostgresPR::UnknownAuthType
- PostgresPR::UnknownMessageType
- Buffer
- Buffer::EOF
- Buffer::Error
- Postgres
- Postgres::Conversion
- Postgres::Conversion::ConversionError
- BinaryReaderMixin
- BinaryWriterMixin
- ByteOrder
- DatabaseError
- Error
- IO
- PGError
- PGconn
- PGresult
- TC_Conversion

No matching classes.

# 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/pg-compat.rb, line 90
    def initialize(res)
      @res = res
      @fields = @res.fields.map {|f| f.name}
      @result = []
      @res.rows.each do |row|
        @result << REXML::SyncEnumerator.new(fields, row).map {|name, value| [name, value]}
      end
    end

### Public Instance Methods

[](index) click to toggle source

    # File lib/postgres-pr/pg-compat.rb, line 86
    def [](index)
      @result[index]
    end

clear() click to toggle source

free the result set

    # File lib/postgres-pr/pg-compat.rb, line 153
    def clear
      @res = @fields = @result = nil
    end

cmd_tuples() click to toggle source
Alias for: cmdtuples
cmdstatus() click to toggle source

    # File lib/postgres-pr/pg-compat.rb, line 148
    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/pg-compat.rb, line 158
    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

Also aliased as: cmd_tuples, cmd_tuples
each(&block) click to toggle source

    # File lib/postgres-pr/pg-compat.rb, line 82
    def each(&block)
      @result.each(&block)
    end

fieldname(index) click to toggle source

    # File lib/postgres-pr/pg-compat.rb, line 115
    def fieldname(index)
      @fields[index]
    end

fieldnum(name) click to toggle source

    # File lib/postgres-pr/pg-compat.rb, line 119
    def fieldnum(name)
      @fields.index(name)
    end

ftype(index) click to toggle source
Alias for: type
getvalue(tup_num, field_num) click to toggle source

    # File lib/postgres-pr/pg-compat.rb, line 136
    def getvalue(tup_num, field_num)
      @result[tup_num][field_num]
    end

nfields() click to toggle source
Alias for: num_fields
ntuples() click to toggle source
Alias for: num_tuples
num_fields() click to toggle source

    # File lib/postgres-pr/pg-compat.rb, line 109
    def num_fields
      @fields.size
    end

Also aliased as: nfields, nfields
num_tuples() click to toggle source

    # File lib/postgres-pr/pg-compat.rb, line 103
    def num_tuples
      @result.size
    end

Also aliased as: ntuples, ntuples
size(index) click to toggle source

    # File lib/postgres-pr/pg-compat.rb, line 130
    def size(index)
      raise
      # TODO: correct?
      @res.fields[index].typlen
    end

status() click to toggle source

    # File lib/postgres-pr/pg-compat.rb, line 140
    def status
      if num_tuples > 0
        TUPLES_OK
      else
        COMMAND_OK
      end
    end

type(index) click to toggle source

    # File lib/postgres-pr/pg-compat.rb, line 123
    def type(index)
      # TODO: correct?
      @res.fields[index].type_oid
    end

Also aliased as: ftype, ftype

[Validate]

Generated with the Darkfish Rdoc Generator 2.