Re: [CDBI] Re: Retrieve only one result from a has_many

[prev] [thread] [next] [Date index for 2005/12/18]

From: Matt S Trout
Subject: Re: [CDBI] Re: Retrieve only one result from a has_many
Date: 16:00 on 18 Dec 2005
On Sat, Dec 17, 2005 at 06:51:46PM -0500, Matt Adams wrote:
> > Did you see this section in the documentation?
> >
> >    http://search.cpan.org/~tmtm/Class-DBI/lib/Class/DBI.pm#Limiting
> >
> > Assuming dset in the deadline table is unique for a given versioncode,
> > maybe something like this:
> 
> Yes, dset in the deadline table is unique for a given versioncode.
> 
> >
> >    ($specific_deadline) = $object->deadlines(dset => 5);
> 
> Ed,
> 
> Thank you for your suggestions and clarifications.  My apologies for the
> poor examples I provided; I think I was half asleep when I typed the
> e-mail.
> 
> What I am really looking for is to be able to issue something like:
> 
> MyApp::DB::Deadline->has_a( versioncode => 'MyApp::DB::Version' );
> MyApp::DB::Version->has_many( deadlines => 'MyApp::DB::Deadline' );
> 
> And some other cool magic which I'm hoping someone can supply.
> 
> And when I retrieve a record via
> 
> $object = MyApp::DB::Version->retrieve( 23 );
> 
> Be able to get a specific value from the has_many relationship to
> MyApp::DB::Deadline by simply issuing
> 
> my $specific_deadline = $object->deadlines;
> 
> In other words, is it possible to limit the results returned from
> $object->deadlines based on information I supply when I create the CDBI
> relationships?

Why not just add a 'sub specific_deadline' to the class that calls
$self->deadlines with appropriate magic?

        -- 
             Matt S Trout       Offering custom development, consultancy and support
  Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +

_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

[CDBI] Re: Retrieve only one result from a has_many
Edward J. Sabol 22:59 on 16 Dec 2005

Re: [CDBI] Re: Retrieve only one result from a has_many
Matt S Trout 16:00 on 18 Dec 2005

Generated at 09:31 on 23 Jan 2006 by mariachi v0.52