[CDBI] Re: Retrieve only one result from a has_many
Matt S Trout
dbix-class at trout.me.uk
Sun Dec 18 16:00:53 GMT 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);
> 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
> 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
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/ +
More information about the ClassDBI