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

Matt Adams matt.adams at morcor.com
Sat Dec 17 23:51:46 GMT 2005

> 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

Thanks for your help.  Its is entirely possible that I'm trying to be too
simple about what I'm doing and that I should just give up now and use the
existing CDBI functionality to get what I want.



More information about the ClassDBI mailing list