[jifty-devel] simple group by

Dobrica Pavlinusic dpavlin at rot13.org
Thu Apr 10 19:15:02 EDT 2008


Is it possible to model something like

select count(l),l from organizations group by l order by count desc

using Jifty::Collection ?

I have something like:

$orgs->group_by( column => 'l' );
$orgs->order_by( column => 'l', order => 'desc' );
$orgs->column( column => 'l', function => 'count(l)' );

which is good for count, but I can't get original name. If I do
something like:

$orgs->column( column => 'count', function => 'count(l)' );
$orgs->column( column => 'l' );

SQL query examined with

$orgs->build_select_query

Looks fine:

SELECT count(l) AS main_count, main.l AS main_l FROM organizations main
GROUP BY main.l  ORDER BY main.l DESC

but I can't access main_count from resulting object (which somehow makes
sense). Is there any way to access count *and* name at time same time?

-- 
Dobrica Pavlinusic               2share!2flame            dpavlin at rot13.org
Unix addict. Internet consultant.             http://www.rot13.org/~dpavlin


More information about the jifty-devel mailing list