| Class | FlexiRecord::BaseRecord |
| In: |
lib/flexirecord.rb
|
| Parent: | FlexiRecord::AbstractRecord |
A record representing a row of a database table or query result.
Adds two ManyToOneReferences and connects them to form a many-to-many relation between two other record classes. Please look at the FlexiRecordDemo module to see how this works.
Adds a ManyToOneReference to the class (by simply creating it). The first argument is the destination class, followed by arguments being passed to Reference.new.
Adds an OneToOneReference to the class (by simply creating it). The first argument is the destination class, followed by arguments being passed to Reference.new.
Autodetects the columns (and primary key columns) of the underlaying table, to be later retrieved by the ‘columns’ and the ‘primary_columns’ methods.
Executes the given SQL command with optional arguments on the database being used to store objects of this class. Returns nil.
Executes the given SQL query with optional arguments on the database being used to store objects of this class. Returns an array of BaseRecord‘s (but NOT sub-classes of BaseRecord) containing the data of all rows of the query result.
Executes the given SQL query with optional arguments on the database being used to store objects of this class. Returns an array of BaseRecord‘s (but NOT sub-classes of BaseRecord) containing the data of the first row of the query result.
Returns the isolation_level of a transaction in progress on the connection used for accessing the table of this class.
Locks the table used to store objects of this class. Calling this command only makes sense, if a transaction is in progress.
Modifies a parameter array by replacing "shortcut" symbols being defined by add_read_option. Returns the parameter array.
Returns the database schema name of this class (or of it‘s superclass, if it has no own schema name)
Returns the database schema name, even if no schema is set (in this case "public" is returned).
Executes an SQL query, selecting rows matching a given set of keys and values, optionally appending a given SQL snippet with parameters. Returns an Array of records.
Sets a given block to be the "loader function" for a particular attribute. Loader functions are invoked, when you try to read an uncached value of the given attribute of a record, or when you preload data for a whole Array of records. Two arguments are passed to the block. The first is an Array of records, whose data is to be loaded, the second is an Array of arguments passed to the method used for accessing the value. The block has to evaluate to an Array of records, which can be used for more than one level deep preloads.
Sets a given block to be the "reader function" for a particlular attribute. A reader function is invoked, when you try to read a value of the given attribute of a record. Two arguments are passed to the block. The first is the record, whose data is to be read, the second is an Array of arguments passed to the method used for reading the value. The block has to evaluate to the value which should be read.
Sets a given block to be the "setter function" for a particular attribute. The setter function is invoked, when you set the value of the given attribute of a record. Two arguments are passed to the block. The first is the record, whose data is to be changed, the second is the new value to be written into the field.
Executes the given SQL query with optional arguments on the database being used to store objects of this class. Returns an array of objects of the class this method is used on (containing the data of all rows of the query result).
Executes the given SQL query with optional arguments on the database being used to store objects of this class. Returns a single object of the class this method is used on (containing the data of the first row of the query result.)
Sets the database table name for this class. This must only be used on sub-classes of BaseRecord, and never on BaseRecord itself.
Returns the ConnectionPool being used for the current thread, if an explicit pool was set for the current thread.
Wraps the given block in a transaction of the database being used to store objects of this class. See FlexiRecord::Connection#transaction for details of the command.
Returns true, if a transaction is in progress on the connection used for accessing the table of this class.
Calls the given block with a Connection object to the database being used to store objects of this class.
Reads a value (whose key can consist of multiple fields) from the internal cache. The first argument is by convention usually a name of a column as String(!), but NOT as a Symbol.
Writes a value to the internal cache. The first argument is by convention usually a name of a column as String(!), but NOT as a Symbol.
Reloads the record from the database. It can not be used on records, which have not been saved to the database yet.
Replaces the internal state with the state of a backup. This method is needed for transaction rollbacks.
Wraps the given block in a transaction of the database being used to store the object. See FlexiRecord::Connection#transaction for details of the command. This object is automatically passed to the FlexiRecord::Connection#transaction method, to rollback changes, in case an Error is raised.
Rewrites several attributes given by the keys and values in the ‘data’ hash. Note: A SQL UPDATE command is not executed before ‘save’ is called, this method just updates the ruby object. Returns self.