[Dbix-class] DBIx::Class:Schema::Loader has_many relationshipnames

Adam Sjøgren asjo at koldfront.dk
Fri Feb 24 21:25:12 CET 2006


On Fri, 24 Feb 2006 20:13:32 +0000, Matt wrote:

> my $car = $schema->resultset('Car')->find('Ford Focus');

And in Catalyst it would be something like
$c->model('DBIC')->resultset('Car')->find('Fiat Golf'), right?

(I thought I read somewhere that $c->model('DBIC::Car')->find('...') 
would work [with D::C::S::Loader], but I haven't been able to make it
do so. And I can't find it now. Hm.

This would be where my head would have to adapt to the missing plural
's').

>> So my answer would be that the second 'my' should be 'my $cars=' and
>> hold a recordset - each record in that should be of a class called
>> MyApp::Car, representing one car.

> That's what a DBIx::Class::ResultSet is for.

Yep, got that.

> What I usually do is declare a custom ResultSet class called 'DB::Cars'

> so

> my $DB_Cars = $schema->resultset('Car');

> my @DB_Car = $DB_Cars->all;

That went over my head - where do you use DB::Cars in the above (I
just see a variable, $DB_Cars, with a good and convenient name)?
 
>> (I (think I) understand that that kind of naming does not map really
>> well to the way the ORM works, but above I'm just stating what makes
>> sense "in my head", when I read it. My head will have to adapt).

> I think you might be wrong - see above.

I probably didn't articulate where my head has to adapt clearly
enough.

Anyway, I'm be happy to be wrong in this particular case... :-)

> The separation of ResultSource (table), ResultSet (recordset) and
> Row classes in 0.05 was specifically so you could end up with a
> sensible mapping of such concepts to OO-land :)

Great! I probably need to do some more reading than just the
Schema-intro...


  Best regards,

    Adam

-- 
 "Commandeer! We're going to 'commandeer' that ship.          Adam Sjøgren
  Nautical term."                                        asjo at koldfront.dk




More information about the Dbix-class mailing list