<div class="gmail_quote">On Wed, Jun 10, 2009 at 12:15 PM, Jonathan Otsuka <span dir="ltr"><<a href="mailto:djgoku@gmail.com">djgoku@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style=""><span style="font-family: Times;"><div><div> $c->stash->{stuff} = [</div><div> $c->model('DB::Blah')->search(</div><div> {},</div><div> { select => ['data', { count => 'data' }], group_by => ['data '] }</div>
<div> )</div><div> ];</div></div></span></div></blockquote><div><br>You want <a href="http://search.cpan.org/%7Eribasushi/DBIx-Class-0.08104/lib/DBIx/Class/ResultSet.pm#as">the "as" attribute</a> on your query:<br>
</div><div><br> <span style="font-family: courier new,monospace;">$c->model('DB::Blah')->search(</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {},</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> { select => [ 'data', { count => 'data' } ],</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> as => [ 'data', 'cnt' ],</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> group_by => [ 'data' ],</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> },</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">);</span><br style="font-family: courier new,monospace;"><br>And then:<br><br><span style="font-family: courier new,monospace;">$rec->data;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">$rec->get_column('cnt');</span><br style="font-family: courier new,monospace;"><br>Note the necessity of using get_column here, since "cnt" is not an actual table column and thus won't have an auto-generated accessor method.<br>
</div></div><br>-- <br>Stephen Clouse <<a href="mailto:stephenclouse@gmail.com">stephenclouse@gmail.com</a>><br>