[Catalyst] schema

Robert 'phaylon' Sedlacek rs at 474.at
Sun Dec 24 22:02:15 GMT 2006


Octavian Rasnita said:

>> Beware though that this probably means you can't access a DBIC resultset
>> directly via $c->model('DB::Foo');
>
> Ok, but how?

Um, how _what_? It would be very helpful if you'd write whole questions,
not assuming that I know what is on your mind. We both seem to be
non-native english speakers and it would surely make this conversation
easier for us both.

Anyway, I'll just elaborate my statement:

While you can access your DBIC schema through $c->model('DB'), The
C:Model::DBIC::Schema provides you with a shortcut, because most of the
time you want a resultset, not the schema. This allows you to do, for
example, $c->model('DB::Person') to retrieve the 'Person' resultset in the
'DB' schema. This means you can do

  my $barneys = $c->model('DB::Person')->search({name => 'barney'});

instead of

  my $schema = $c->model('DB');
  my $barnes = $schema->resultset('Person')->search({name => 'barney'});

And I don't think Model::DBIC::Schema pays attention to the default_model
setting.

-- 
# Robert 'phaylon' Sedlacek
# Perl 5/Catalyst Developer in Hamburg, Germany
{ EMail => ' rs at 474.at ', Web => ' http://474.at ' }




More information about the Catalyst mailing list