[Dbix-class] Counting one to many
Dan Horne
dan.horne at redbone.co.nz
Mon Jun 29 22:02:10 GMT 2009
Brilliant - exactly what I was after
On 30/06/2009, at 09:52 AM, Rob Kinyon wrote:
> 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
>
> _______________________________________________
> 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
More information about the DBIx-Class
mailing list