[Dbix-class] Counting one to many
Dan Horne
dan.horne at redbone.co.nz
Mon Jun 29 21:48:40 GMT 2009
Hi
Say I have two tables, invoices and invoice_lines, where the
relationship is one to many. If we pass a resultset of the invoices to
a TT template, is it possible to chain an a method on the resultset to
get a count of he invoice lines? I don't mind going back to the db to
do exta fetches per line as there will never be more than 20 invoices.
i.e., I want to do something like this:
[% WHILE (invoice = invoices.next) %]
<tr>
<td>[% invoice.invoice_number %]</td>
<td>[% invoice.invoice_lines.count %]</td> <-- something
that does this
</tr>
[% END %]
Regards
Dan
More information about the DBIx-Class
mailing list