<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jun 10, 2009, at 1:39 PM, Stephen Clouse wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><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-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); margin-top: 0pt; margin-right: 0pt; margin-bottom: 0pt; margin-left: 0.8ex; padding-left: 1ex; position: static; z-index: auto; "> <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></blockquote></div><br><div>Hooray!!! Thank you! I didn't think of using an alias!</div><div><br></div><div>Jonathan</div></body></html>