You can call method ->get_column('some_value')->min from resultset. <br>Also you can create your own ResultSet and add method<br><br>sub get_min_malue {<br> shift->get_column('some_column')->min;<br>
}<br><br>So you can make such query:<br>$c->model('DB::Table')->get_min_value;<br>$c->model('DB::Table')->search( {type => 1} )->get_min_value;<br><br>But you will make three requests for min, max and avg functions. Or you can create other method in your resultset object which returns hash with needed values.<br>
<br>sub get_stats_data{<br> return { min => 1, max => 2, avg => 3}<br>}<br><br><div class="gmail_quote">2009/9/22 Trevor Phillips <span dir="ltr"><<a href="mailto:trevor.phillips@gmail.com">trevor.phillips@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">2009/9/21 Андрей Костенко <<a href="mailto:andrey@kostenko.name">andrey@kostenko.name</a>>:<br>
<div class="im">> You can create a view for this query. e.g.<br>
> CREATE VIEW stats AS SELECT MIN(a), MAX(a), AVG(a) FROM table1;<br>
<br>
</div>I could, but it's not the query I'm having a problem with - it's<br>
mapping it to columns within the pre-existing DBIx::Class. I'd rather<br>
not have to create a whole new class simply for this single query<br>
against my data. I can see the data in the raw object - I just can't<br>
access it through the normal methods.<br>
<br>
Reading the manual, I should be able to get the value via get_column,<br>
but Catalyst/TT uses the column methods instead.<br>
<br>
Hmmm, I *can* use get_column within TT, but that seems to defeat the<br>
purpose of abstracting data from presentation.<br>
<br>
When getting the search results, I can map the rows with<br>
$_->get_columns(). That seems to be the easiest solution for now.<br>
<div><div></div><div class="h5"><br>
--<br>
Trevor Phillips - <a href="http://dortamur.livejournal.com/" target="_blank">http://dortamur.livejournal.com/</a><br>
"On nights such as this, evil deeds are done. And good deeds, of<br>
course. But mostly evil, on the whole."<br>
-- (Terry Pratchett, Wyrd Sisters)<br>
<br>
_______________________________________________<br>
List: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class</a><br>
IRC: <a href="http://irc.perl.org#dbix-class" target="_blank">irc.perl.org#dbix-class</a><br>
SVN: <a href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/" target="_blank">http://dev.catalyst.perl.org/repos/bast/DBIx-Class/</a><br>
Searchable Archive: <a href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk" target="_blank">http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk</a><br>
</div></div></blockquote></div><br>