DBIx::StORM::Record |
DBIx:: | |
DBIx:: | A 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 |
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
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 |
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.
HashRef $params | Parameters to build the Record |
Object | A new DBIx::StORM::Record object |
=end NaturalDocs
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.
$field | The field to fetch from the row |
Tied scalar as an l-value | The scalar may be a reference, and is tied to class DBIx::StORM::TiedCallback |
=end NaturalDocs
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.
$field | The string column name to fetch |
Variable | undef 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
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.
None
String | a printable value for this result |
=end NaturalDocs
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.
None
Nothing
=end NaturalDocs
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.
String $field | The field that has just been changed. |
Scalar $new_value | Optionally, 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(). |
Nothing
=end NaturalDocs
Create a new DBIx::StORM::Record object from the RecordSet.
sub _new
Used by overloading to provide hash-reference access.
sub _as_tied_hash
Fetch a field from the Record.
sub get : lvalue
Fetch the scalar value of a “simple” (ie.
sub _get_simple_value
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 _build_column_information_for_get
A string representation of the Record, used for overloading.
sub _as_string
Whether to write changed rows back to the database as soon as possible.
sub autocommit : lvalue
sub _not_invalid
sub _as_bool
sub delete
sub commit
sub refresh
sub _update_content
sub _fields
sub _update_field
Find Records in another table that have a foreign key that links back to this record.
sub associated
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 updated
sub TIEHASH
sub FETCH
sub STORE
sub EXISTS
sub FIRSTKEY
sub NEXTKEY
sub SCALAR