NAME
Jifty::DBI::Record - Superclass for records loaded by Jifty::DBI::Collection
SYNOPSIS
package MyRecord;
use base qw/Jifty::DBI::Record/;
DESCRIPTION
Jifty::DBI::Record encapuslates records and tables as part of the Jifty::DBI object-relational mapper.
METHODS
new
Instantiate a new, empty record object.
id
Returns this row's primary key.
primary_keys
Return a hash of the values of our primary keys for this function.
_parse_autoload_method $AUTOLOAD
Parses autoload methods and attempts to determine if they're set, get or validate calls.
Returns a tuple of (COLUMN_NAME, ACTION);
_accessible COLUMN ATTRIBUTE
Private method.
DEPRECATED
Returns undef unless COLUMN
has a true value for ATTRIBUTE
.
Otherwise returns COLUMN
's value for that attribute.
_primary_keys
Return our primary keys. (Subclasses should override this, but our default is that we have one primary key, named 'id'.)
_init_columns
Sets up the primary key columns.
_to_record COLUMN VALUE
This PRIVATE method takes a column name and a value for that column.
It returns undef
unless COLUMN
is a valid column for this record that refers to another record class.
If it is valid, this method returns a new record object with an id of VALUE
.
add_column
column
readable_attributes
Returns a list this table's readable columns
writable_attributes
Returns a list of this table's writable columns
__value
Takes a column name and returns that column's value. Subclasses should never override __value.
_value
_value takes a single column name and returns that column's value for this row. Subclasses can override _value to insert custom access control.
_set
_set takes a single column name and a single unquoted value. It updates both the in-memory value of this column and the in-database copy. Subclasses can override _set to insert custom access control.
_Validate column VALUE
Validate that value will be an acceptable value for column.
Currently, this routine does nothing whatsoever.
If it succeeds (which is always the case right now), returns true. Otherwise returns false.
load
Takes a single argument, $id. Calls load_by_cols to retrieve the row whose primary key is $id
load_by_cols
Takes a hash of columns and values. Loads the first record that matches all keys.
The hash's keys are the columns to look at.
The hash's values are either: scalar values to look for OR has references which contain 'operator' and 'value'
load_by_primary_keys
load_from_hash
Takes a hashref, such as created by Jifty::DBI and populates this record's loaded values hash.
_load_from_sql QUERYSTRING @BIND_VALUES
Load a record as the result of an SQL statement
create
Takes an array of key-value pairs and drops any keys that aren't known as columns for this recordtype
delete
Delete this record from the database. On failure return a Class::ReturnValue with the error. On success, return 1;
table
This method returns this class's default table name. It uses Lingua::EN::Inflect to pluralize the class's name as we believe that class names for records should be in the singular and table names should be plural.
If your class name is My::App::Rhino
, your table name will default to rhinos
. If your class name is My::App::RhinoOctopus
, your default table name will be rhino_octopuses
. Not perfect, but arguably correct.
_guess_table_name
Guesses a table name based on the class's last part.
_handle
Returns or sets the current Jifty::DBI::Handle object
used for the declarative syntax
AUTHOR
Jesse Vincent, <jesse@fsck.com>
Enhancements by Ivan Kohler, <ivan-rt@420.am>
Docs by Matt Knopp <mhat@netlag.com>