Hi,

I have two tables t1 and t2 linked through a one-to-many relationship.
Each record in t1 has 0 or more corresponding records in t2. Given a
My::T1 object, I would like to get an average on a column in t2 for
all rows corresponding to the My::T1 row.

t1 (id, name)
-----------------------
1, 'my name'

t2 (id, t1_id_fk, price)
-----------------------
1, 1, 15
2, 1, 20

my $t1 = My::T1->new(id => 1)->load();
$t1->average_price(); # should give 17.5

I found an old post on the subject
(http://osdir.com/ml/lang.perl.modules.dbi.rose-db-object/2006-08/msg00077.html)
but am not sure how to implement this in a one-to-many context.

TIA.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to