[CDBI] Retrieve only one result from a has_many

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

From: Matt Adams
Subject: [CDBI] Retrieve only one result from a has_many
Date: 22:36 on 16 Dec 2005
Hello fellow CDBI users:

I have an interesting situation concerning the use of a has_many 
relationship.

I have two tables.  For the sake of simplicity let's assume that they 
are called "version" and "deadline" where there can be many deadlines 
for any given version.

I have the following CDBI relationships set up like this:

MyApp::DB::Deadline->has_a( versioncode => 'MyApp::DB::Version' );
MyApp::DB::Version->has_many( deadlines => 'MyApp::DB::Deadline' );

Now, when I retrieve a particular version via

$object = $MyApp::DB::Version->retrieve( 23 );

I get back a bunch of nifty looking objects with blessed references to 
the related deadlines (which is cool if I need to iterate over a number 
of deadlines and whatnot).

Here is my problem:

I have a situation where I must retrieve one particular deadline for a 
specific version and even though I have a has_many relationship here I 
only want to get the value of the specific deadline according to a 
column value in MyApp::DB::Deadline (say the column is something like 
deadline.dset).

So, when I retrieve a version like the $class->retrieve() above I don't 
want a blessed reference to ALL of the related deadlines; I only want to 
get back a blessed reference (or perhaps not a reference at all but a 
value) of the related deadlines with the deadline.dset value of 5.

Is there a simple way to go about this?

Any suggestions or comments would be greatly appreciated.


Thank you,

Matt

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

[CDBI] Retrieve only one result from a has_many
Matt Adams 22:36 on 16 Dec 2005

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

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