DBIx::StORM::Record

DBIx::StORM::Record
Summary
DBIx::StORM::Record
DBIx::StORM::RecordA StORM class representing an individual row from the database.
Functions
_new (private instance)Create a new DBIx::StORM::Record object from the RecordSet.
_as_tied_hash (private instance)Used by overloading to provide hash-reference access.
get (public instance)Fetch a field from the Record.
_get_simple_value (private instance)Fetch the scalar value of a “simple” (ie.
_build_column_information_for_get (private instance)Turn a string column name into a fully qualified content path, and also check to see if it’s a foreign key lookup and fetch the result if so.
_as_string (private instance)A string representation of the Record, used for overloading.
autocommit (public instance)Whether to write changed rows back to the database as soon as possible.
_not_invalid
_as_bool
delete
commit
refresh
_update_content
_fields
_update_field
associated (public instance)Find Records in another table that have a foreign key that links back to this record.
updated (public instance)Marks a field as having been changed, which will either push the field onto the list of fields that need to be written back or will trigger an immediate write to the database if autocommit is set.
TIEHASH
FETCH
STORE
EXISTS
FIRSTKEY
NEXTKEY
SCALAR

DBIx::StORM::Record

DBIx::StORM::Record

A StORM class representing an individual row from the database.

This is essentially a wrapper for a result from a DBI statement handle.  It appears to be a hash reference, where the keys of the hash are the column names in the result and the hash values are the column values.

=end NaturalDocs

Summary
Functions
_new (private instance)Create a new DBIx::StORM::Record object from the RecordSet.
_as_tied_hash (private instance)Used by overloading to provide hash-reference access.
get (public instance)Fetch a field from the Record.
_get_simple_value (private instance)Fetch the scalar value of a “simple” (ie.
_build_column_information_for_get (private instance)Turn a string column name into a fully qualified content path, and also check to see if it’s a foreign key lookup and fetch the result if so.
_as_string (private instance)A string representation of the Record, used for overloading.
autocommit (public instance)Whether to write changed rows back to the database as soon as possible.
_not_invalid
_as_bool
delete
commit
refresh
_update_content
_fields
_update_field
associated (public instance)Find Records in another table that have a foreign key that links back to this record.
updated (public instance)Marks a field as having been changed, which will either push the field onto the list of fields that need to be written back or will trigger an immediate write to the database if autocommit is set.
TIEHASH
FETCH
STORE
EXISTS
FIRSTKEY
NEXTKEY
SCALAR

Functions

_new (private instance)

sub _new

Create a new DBIx::StORM::Record object from the RecordSet.  The Record may cover data from a lot of tables as it may have information for tables accessed as foreign keys.  Therefore a result has a concept of “base reference” which is the access path to this result, which is used to index into the map of columns.

Parameters

HashRef $paramsParameters to build the Record

Returns

ObjectA new DBIx::StORM::Record object

=end NaturalDocs

_as_tied_hash (private instance)

sub _as_tied_hash

Used by overloading to provide hash-reference access.  The keys of this hash are the columns in the result (for this table only) and the values are the column values.

Parameters

None

Returns

HashRefA tied hash of the column information

=end NaturalDocs

get (public instance)

sub get : lvalue

Fetch a field from the Record.  The field is returned as an l-value, so you can assign to it.  This is for people who don’t like the hash-reference style access.

Parameters

$fieldThe field to fetch from the row

Returns

Tied scalar as an l-valueThe scalar may be a reference, and is tied to class DBIx::StORM::TiedCallback

=end NaturalDocs

_get_simple_value (private instance)

sub _get_simple_value

Fetch the scalar value of a “simple” (ie. not foreign key) column.  This is used by TiedCallback.

Parameters

$fieldThe qualified field to fetch
$raw_fieldThe string field name

Returns

Scalarthe column value, or undef on failure

=end NaturalDocs

_build_column_information_for_get (private instance)

sub _build_column_information_for_get

Turn a string column name into a fully qualified content path, and also check to see if it’s a foreign key lookup and fetch the result if so.

Parameters

$fieldThe string column name to fetch

Returns

Variableundef on failure, one DBIx::StORM::Record on a foreign key lookup or a ($field, $raw_field) pair suitable for feeding to _get_simple_value for non-foreign columns.

=end NaturalDocs

_as_string (private instance)

sub _as_string

A string representation of the Record, used for overloading.  We stringify to the primary key where possible.  This may sound perverse, but it means that

print $result->{foreign_key};

gives you the foreign key value as you’d expect.  It also makes for a reasonable serialisation.  If there is no primary key we serialise in the standard Perl fashion.

Parameters

None

Returns

Stringa printable value for this result

=end NaturalDocs

autocommit (public instance)

sub autocommit : lvalue

Whether to write changed rows back to the database as soon as possible.  This is my default true for rows loaded from a table, and false before a new row is inserted.

Auto committing can thrash the database with small queries if you make a lot of updates to a row quickly, so turning off autocommit will allow those changes to be written back with one query.

Parameters

None

Returns

Nothing

=end NaturalDocs

_not_invalid

sub _not_invalid

_as_bool

sub _as_bool

delete

sub delete

commit

sub commit

refresh

sub refresh

_update_content

sub _update_content

_fields

sub _fields

_update_field

sub _update_field

associated (public instance)

sub associated

Find Records in another table that have a foreign key that links back to this record.

Parameters

String $tableTable to scan for links back to this record

Returns

ObjectA DBIx::StORM::RecordSet of records with a column that match

=end NaturalDocs

updated (public instance)

sub updated

Marks a field as having been changed, which will either push the field onto the list of fields that need to be written back or will trigger an immediate write to the database if autocommit is set.

This allows the user to mark a field as changed where the change is made to an inner part of a data structure (as in this case no STORE() occurs on the outer data structure, so we don’t even know that it is happening.

Parameters

String $fieldThe field that has just been changed.
Scalar $new_valueOptionally, the new value that has just been assigned.  This is intended for internal use to save the overhead of fetching the new value using get().

Returns

Nothing

=end NaturalDocs

TIEHASH

sub TIEHASH

FETCH

sub FETCH

STORE

sub STORE

EXISTS

sub EXISTS

FIRSTKEY

sub FIRSTKEY

NEXTKEY

sub NEXTKEY

SCALAR

sub SCALAR
sub _new
Create a new DBIx::StORM::Record object from the RecordSet.
sub _as_tied_hash
Used by overloading to provide hash-reference access.
sub get : lvalue
Fetch a field from the Record.
sub _get_simple_value
Fetch the scalar value of a “simple” (ie.
sub _build_column_information_for_get
Turn a string column name into a fully qualified content path, and also check to see if it’s a foreign key lookup and fetch the result if so.
sub _as_string
A string representation of the Record, used for overloading.
sub autocommit : lvalue
Whether to write changed rows back to the database as soon as possible.
sub _not_invalid
sub _as_bool
sub delete
sub commit
sub refresh
sub _update_content
sub _fields
sub _update_field
sub associated
Find Records in another table that have a foreign key that links back to this record.
sub updated
Marks a field as having been changed, which will either push the field onto the list of fields that need to be written back or will trigger an immediate write to the database if autocommit is set.
sub TIEHASH
sub FETCH
sub STORE
sub EXISTS
sub FIRSTKEY
sub NEXTKEY
sub SCALAR
Close