DBIx::StORM::Table

DBIx::StORM::Table
Summary
DBIx::StORM::Table
DBIx::StORM::TableAn StORM class representing a table.
Functions
_new (private instance)Create a new DBIx::StORM::Table object from a connection.
_get_sth (private instance)Actually run the query using the DBI and the SQLDriver and return a result statement handle.
name (public instance)Get the name of the table this object represents
insert (public instance)Insert a new row into the table
_filter_id (private instance)All RecordSets need a unique string identifier which is used for caching.
primary_key (public instance)Fetch a list of all the primary key column names in this table.
foreign_keys (public instance)Fetch a hash of all the foreign keys in this table.
grep (public instance)Filter this DBIx::StORM::RecordSet by applying a result filter.
sort (public instance)Sort this DBIx::StORM::RecordSet by applying a sort routine.
grep_pp (public instance)Filter this DBIx::StORM::RecordSet using a perl filter.
_build_result_identity
_rebuild_record (private instance)This is called by a DBIx::StORM::Record when the content has changed or the column set loaded is incorrect.
_get_record_for_fk (private instance)When a foreign key column in a Record from this table is access, this method is called to generate the Record record for the foreign key.
_table (private instance)All RecordSets need to be able to quickly fetch the underlying DBIx::StORM::Table object it is derived from.
identity (public instance)Fetch the record that has a given primary key value.
PUSH (private instance)Insert a new row into the table through array emulation.

DBIx::StORM::Table

DBIx::StORM::Table

An StORM class representing a table.

This class inherits from DBIx::StORM::RecordSet, so can be grep’d (filtered), and sorted.  You can also insert new rows.  Tables can be array dereferenced to iterate over the rows in the table.

=end NaturalDocs

Summary
Functions
_new (private instance)Create a new DBIx::StORM::Table object from a connection.
_get_sth (private instance)Actually run the query using the DBI and the SQLDriver and return a result statement handle.
name (public instance)Get the name of the table this object represents
insert (public instance)Insert a new row into the table
_filter_id (private instance)All RecordSets need a unique string identifier which is used for caching.
primary_key (public instance)Fetch a list of all the primary key column names in this table.
foreign_keys (public instance)Fetch a hash of all the foreign keys in this table.
grep (public instance)Filter this DBIx::StORM::RecordSet by applying a result filter.
sort (public instance)Sort this DBIx::StORM::RecordSet by applying a sort routine.
grep_pp (public instance)Filter this DBIx::StORM::RecordSet using a perl filter.
_build_result_identity
_rebuild_record (private instance)This is called by a DBIx::StORM::Record when the content has changed or the column set loaded is incorrect.
_get_record_for_fk (private instance)When a foreign key column in a Record from this table is access, this method is called to generate the Record record for the foreign key.
_table (private instance)All RecordSets need to be able to quickly fetch the underlying DBIx::StORM::Table object it is derived from.
identity (public instance)Fetch the record that has a given primary key value.
PUSH (private instance)Insert a new row into the table through array emulation.

Functions

_new (private instance)

sub _new

Create a new DBIx::StORM::Table object from a connection.

Parameters

Object $stormA connection of type DBIx::StORM
String $tableThe table name as a string

Returns

ObjectA new DBIx::StORM::Table object

=end NaturalDocs

_get_sth (private instance)

sub _get_sth

Actually run the query using the DBI and the SQLDriver and return a result statement handle.  This is a simpler, speedier version of that in DBIx::StORM::RecordSet.

Parameters

None

Returns

ObjectThe DBI statement handle of results
HashA hash map of column references to result array indices

=end NaturalDocs

name (public instance)

sub name

Get the name of the table this object represents

Parameters

None

Returns

StringThe table name as a string

=end NaturalDocs

insert (public instance)

sub insert

Insert a new row into the table

Parameters

SubrefA subroutine that initialises the new record, $_ (optional)

Returns

ObjectA row of type DBIx::StORM::Record

=end NaturalDocs

_filter_id (private instance)

sub _filter_id

All RecordSets need a unique string identifier which is used for caching.

For tables this is the table name.

Parameters

None

Returns

StringA cachable identifier for this RecordSet configuration

=end NaturalDocs

primary_key (public instance)

sub primary_key

Fetch a list of all the primary key column names in this table.

Parameters

None

Returns

ListString column names of the primary keys

=end NaturalDocs

foreign_keys (public instance)

sub foreign_keys

Fetch a hash of all the foreign keys in this table.

The hash key is the string name of the foreign key column in this table, and the value is a table reference to the column in the foreign table.

Parameters

None

Returns

HashListDetails of the foreign keys used by this table.

=end NaturalDocs

grep (public instance)

sub grep

Filter this DBIx::StORM::RecordSet by applying a result filter.

Parameters

SubRefThe filter code as a perl subroutine reference

Returns

ObjectA new DBIx::StORM::RecordSet which contains just the matching rows

=end NaturalDocs

sort (public instance)

sub sort

Sort this DBIx::StORM::RecordSet by applying a sort routine.

Parameters

SubRefThe sort code as a perl subroutine reference, similiar to the one used in perl’s sort operator

Returns

ObjectA new DBIx::StORM::RecordSet which contains the same rows sorted

=end NaturalDocs

grep_pp (public instance)

sub grep_pp

Filter this DBIx::StORM::RecordSet using a perl filter.  This is identical to the <grep> method, but does not attempt to parse the subref and optimise it.

Parameters

SubRefThe filter code as a perl subroutine reference

Returns

ObjectA new DBIx::StORM::RecordSet which contains just the matching rows

=end NaturalDocs

_build_result_identity

sub _build_result_identity

_rebuild_record (private instance)

sub _rebuild_record

This is called by a DBIx::StORM::Record when the content has changed or the column set loaded is incorrect.  It causes the object to be rebuilt with a new set of column.  The object is modified in-situ.  The row is selected from the database by primary key column equality, so it won’t work on tables without a PK.

Parameters

Object $recordDBIx::StORM::Record to rebuild
Boolean $fullWhether to fetch all rows, or just the ones requested by the record object

Returns

None

=end NaturalDocs

_get_record_for_fk (private instance)

sub _get_record_for_fk

When a foreign key column in a Record from this table is access, this method is called to generate the Record record for the foreign key.

Parameters

String $columnthe name of the foreign key column
String $valuethe value of the column in the calling record
Object $resultsetthe resultset that the calling record came from
String $base_refthe path to the table the calling record comes from
HashRef $table_mappingthe calling record’s mapping of column references to content indexes
ArrayRef $contentThe column values contained in the calling record

Returns

ObjectA DBIx::StORM::Record

=end NaturalDocs

_table (private instance)

sub _table

All RecordSets need to be able to quickly fetch the underlying DBIx::StORM::Table object it is derived from.

In the case of DBIx::StORM::Table this is the object itself.

Parameters

None

Returns

ObjectObject of type DBIx::StORM::Table

=end NaturalDocs

identity (public instance)

sub identity

Fetch the record that has a given primary key value.  For one-column primary keys you can pass in the value directly.  Otherwise a hash reference should be passed in of field name => field value mappings.

If you incorrectly specify the primary key this function will die.

Parameters

$primary_key_infoEither a value or hashref specifying the primary key value(s) of the desired Record.

Returns

ObjectObject of type DBIx::StORM::Record

=end NaturalDocs

PUSH (private instance)

sub PUSH

Insert a new row into the table through array emulation.

If $row is an object of class DBIx::StORM::Record then it will be inserted into the table (an exception will be thrown if this record was created for a different table.

If $row is a subroutine reference then a new record will be created and passed into the subroutine as $_.  The subroutine can then initalise the record, which will be written to the database on completion of the subroutine.

If $row is a hashref then a new record will be created and the fields will be copied from the hash and into the record.

Parameters

$rowThe record to insert

Returns

$rowsThe number of rows in the table

=end NaturalDocs

sub _new
Create a new DBIx::StORM::Table object from a connection.
sub _get_sth
Actually run the query using the DBI and the SQLDriver and return a result statement handle.
sub name
Get the name of the table this object represents
sub insert
Insert a new row into the table
sub _filter_id
All RecordSets need a unique string identifier which is used for caching.
sub primary_key
Fetch a list of all the primary key column names in this table.
sub foreign_keys
Fetch a hash of all the foreign keys in this table.
sub grep
Filter this DBIx::StORM::RecordSet by applying a result filter.
sub sort
Sort this DBIx::StORM::RecordSet by applying a sort routine.
sub grep_pp
Filter this DBIx::StORM::RecordSet using a perl filter.
sub _build_result_identity
sub _rebuild_record
This is called by a DBIx::StORM::Record when the content has changed or the column set loaded is incorrect.
sub _get_record_for_fk
When a foreign key column in a Record from this table is access, this method is called to generate the Record record for the foreign key.
sub _table
All RecordSets need to be able to quickly fetch the underlying DBIx::StORM::Table object it is derived from.
sub identity
Fetch the record that has a given primary key value.
sub PUSH
Insert a new row into the table through array emulation.
Close