DBIx:: StORM:: Table

DBIx::StORM::Table
Summary
An StORM class representing a table.
Create a new DBIx::StORM::Table object from a connection.
Actually run the query using the DBI and the SQLDriver and return a result statement handle.
Get the name of the table this object represents
Insert a new row into the table
All RecordSets need a unique string identifier which is used for caching.
Fetch a list of all the primary key column names in this table.
Fetch a hash of all the foreign keys in this table.
Filter this DBIx::StORM::RecordSet by applying a result filter.
Sort this DBIx::StORM::RecordSet by applying a sort routine.
Create a new DBIx::StORM::RecordSet with derivable columns added.
Filter this DBIx::StORM::RecordSet using a perl filter.
This is called by a DBIx::StORM::Record when the content has changed or the column set loaded is incorrect.
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.
All RecordSets need to be able to quickly fetch the underlying DBIx::StORM::Table object it is derived from.
Fetch the record that has a given primary key value.

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), sorted and viewed.  You can also insert new rows.  Tables can be array dereferenced to iterate over the rows in the table.

=end NaturalDocs

Summary
Create a new DBIx::StORM::Table object from a connection.
Actually run the query using the DBI and the SQLDriver and return a result statement handle.
Get the name of the table this object represents
Insert a new row into the table
All RecordSets need a unique string identifier which is used for caching.
Fetch a list of all the primary key column names in this table.
Fetch a hash of all the foreign keys in this table.
Filter this DBIx::StORM::RecordSet by applying a result filter.
Sort this DBIx::StORM::RecordSet by applying a sort routine.
Create a new DBIx::StORM::RecordSet with derivable columns added.
Filter this DBIx::StORM::RecordSet using a perl filter.
This is called by a DBIx::StORM::Record when the content has changed or the column set loaded is incorrect.
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.
All RecordSets need to be able to quickly fetch the underlying DBIx::StORM::Table object it is derived from.
Fetch the record that has a given primary key value.

Functions

_new (private instance)

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)

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)

Get the name of the table this object represents

Parameters

None

Returns

StringThe table name as a string

=end NaturalDocs

insert (public instance)

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)

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)

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)

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)

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)

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

view (public instance)

Create a new DBIx::StORM::RecordSet with derivable columns added.

Parameters

HashListThe keys in this has the names of the column to create.  The value may either be a perl subref which defines how the column is calculated, or a string containing a SQL snippet to generate the column

Returns

ObjectA new DBIx::StORM::RecordSet which contains the same rows with the new columns added

=end NaturalDocs

grep_pp (public instance)

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)

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)

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)

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)

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

sub _build_result_identity