[Dbix-class] Counting one to many

Rob Kinyon rob.kinyon at gmail.com
Mon Jun 29 21:52:32 GMT 2009


invoice.invoice_lines_rs.count

Rob

On Mon, Jun 29, 2009 at 17:48, Dan Horne<dan.horne at redbone.co.nz> wrote:
> 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
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
>



-- 
Thanks,
Rob Kinyon



More information about the DBIx-Class mailing list