[Dbix-class] Using joins and aggregate functions with DBIC

Nilson Santos Figueiredo Junior acid06 at gmail.com
Fri May 26 23:17:59 CEST 2006


Hello everyone,

I currently have this issue that I can't manage to solve in any
non-horribly looking way involving tons of inefficient approaches and
hand-made SQL code.

I've got a "task" table which has a many-to-many relationship with a
"user" table, through the table "task_user". I've also got a
"task_log" table which belongs_to "task" and belongs_to "user" (both
has_many "task_logs").

I'm trying to get two things:
1 - the sum of a given field in all "task_logs" given a "task"
2 - the sum of a given field in all "task_logs" given a "task" and an "user"

Right now, I've already tried reading almost everything of DBIx::Class
docs and wasn't able to figure it out. And I really wouldn't be able
to dive into source files today. Thus, I ask for your help.

(Forgive me if my writing is worse than normal, I'm not really
thinking straight today because I've got this terrible cold, maybe
this also has something to do with my inability to solve the problem
by myself.)

I'd be really really thankful if someone could answer me as soon as
they read this message.

Thanks in advance.

-Nilson Santos F. Jr.



More information about the Dbix-class mailing list