| PackageDescription | This is a Catalyst Model for DBIx::Class::Schema-based Models. See the
documentation for Catalyst::Helper::Model::DBIC::Schema for information on
generating these Models via Helper scripts.
When your Catalyst app starts up, a thin Model layer is created as an
interface to your DBIC Schema. It should be clearly noted that the model
object returned by '$c->model('FilmDB')' is NOT itself a DBIC schema or
resultset object, but merely a wrapper proving methods to access the
underlying schema.
In addition to this model class, a shortcut class is generated for each
source in the schema, allowing easy and direct access to a resultset of the
corresponding type. These generated classes are even thinner than the model
class, providing no public methods but simply hooking into Catalyst's
model() accessor via the ACCEPT_CONTEXT mechanism. The complete contents of
each generated class is roughly equivalent to the following:
package MyApp::Model::FilmDB::Actor
sub ACCEPT_CONTEXT {
my ($self, $c) = @_;
$c->model('FilmDB')->resultset('Actor');
}
In short, there are three techniques available for obtaining a DBIC
resultset object:
my $rs = $c->model('FilmDB')->schema->resultset('Actor');
my $rs = $c->model('FilmDB')->resultset('Actor');
my $rs = $c->model('FilmDB::Actor');
In order to add methods to a DBIC resultset, you cannot simply add them to
the source (row, table) definition class; you must define a separate custom
resultset class. This is just a matter of making a
'lib/MyApp/Schema/ResultSet/Actor.pm' class that inherits from
DBIx::Class::ResultSet, if you are using
DBIx::Class::Schema/load_namespaces, the default for helper script
generated schemas.
See DBIx::Class::Manual::Cookbook/"Predefined searches" for information on
definining your own DBIx::Class::ResultSet classes for use with
DBIx::Class::Schema/load_classes, the old default. |