class Object - pg-0.21.0 Documentation

# class Object

### Constants

PGError
PGconn

  The PostgreSQL connection class. The interface for this class is based on libpq, the C application programmer's interface to PostgreSQL. Some familiarity with libpq is recommended, but not necessary.

  For example, to send query to the database on the localhost:

      require 'pg'
      conn = PG::Connection.open(:dbname => 'test')
      res = conn.exec_params('SELECT $1 AS a, $2 AS b, $3 AS c', [1, 2, nil])
      # Equivalent to:
      #  res  = conn.exec('SELECT 1 AS a, 2 AS b, NULL AS c')

  See the PG::Result class for information on working with the results of a query.

PGresult

  The class to represent the query result tuples (rows). An instance of this class is created as the result of every query. You may need to invoke the clear method of the instance when finished with the result for better memory performance.

  Example:

      require 'pg'
      conn = PG.connect(:dbname => 'test')
      res  = conn.exec('SELECT 1 AS a, 2 AS b, NULL AS c')
      res.getvalue(0,0) # '1'
      res[0]['b']       # '2'
      res[0]['c']       # nil

### Public Instance Methods

camelize(lower_case_and_underscored_word) click to toggle source

    # File ext/errorcodes.rb, line 3
    def camelize(lower_case_and_underscored_word)
            lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
    end