[Catalyst] model update
Ryan D Johnson
ryandjohnson at gmail.com
Sat Mar 8 20:27:13 GMT 2008
Alex Povolotsky <tarkhil at over.ru> writes:
> First of all, $c->model('Model::Class') returns DBIx::ResultSet, NOT
> YourApp::Schema::Class. It is quite unclear for me, and seems to be
> illogical, but it is.
If you'd prefer to use things in a more "classic" DBIC style, you could
do something like:
my $thingies = $c->model('MyAppDB')->resultset('Thingy');
It may trouble you, however, that in this style $c->model('MyAppDB')
masquerades as a DBIx::Class::Schema, when in fact it's a
Catalyst::Model::DBIC::Schema. So here's real classic DBIC:
my $schema = $c->model('MyAppDB')->schema;
my $thingies = $schema->resultset('Thingy');
But that's very long to type, so Catalyst::Model::DBIC::Schema does some
magic that gives shortcuts to the resultset:
my $thingies = $c->model('MyAppDB::Thingy');
As far as I am aware, there is no technical reason to use one style over
the others. Pick the style that you like best and use it consistently
across your project. :-)
/rdj
More information about the Catalyst
mailing list