Class FlexiRecord::Connection
In: lib/flexirecord.rb
Parent: Object

A Connection object represents a distinct connection to the database.

Methods

Included Modules

MonitorMixin

Public Class methods

Generates a new Connection object. The passed ‘options’ are a hash, which may contain the following keys:

  • :engine (only :postgresql is supported)
  • :host
  • :port
  • :options
  • :db
  • :user
  • :pass
  • :data_types (used for the PostgreSQL interface to supply a mapping between OID‘s and ruby types, will be set automatically in the hash object, if it is nil or missing)

Public Instance methods

Closes the connection. The connection object must not be used after it is closed.

Same as record_query, but having no ‘record_class’, theirfor returning nil.

Returns the isolation_level of a transaction in progress on this connection.

Same as record_query, but using BaseRecord‘s as ‘record_class’.

Executes an SQL query and returns an Array of objects of ‘record_class’ (which should be a sub-class of BaseRecord). The ‘command_template’ is an SQL statement with ’$’ placeholders to be replaced by the following ‘command_arguments’.

Starts a transaction or "nested transaction" (implemented by using save points), if already one is in progress. The arguments to this function can be an IsolationLevel constant, a symbol representing an IsolationLevel, the special symbol :unless_open or any number of BaseRecord objects, which are copied with BaseRecord#dup and restored with BaseRecord#replace, in case the transaction fails. If :unless_open is specified, and a transaction is already open, this method does nothing, except calling the given block. As partitial rollbacks on errors won‘t happen in this case, it‘s not recommended to use the :unless_open parameter, unless you know what you are doing. IsolationLevel‘s are only regarded, if there is no transaction open yet.

Returns true, if a transaction is in progress on this connection.

[Validate]