Ok, I have what I want working. I'm doing this:
my $lists = $schema->resultset('BOLTopLists::Lists')->search(
{
'toplist.market' => 'charlotte',
},
{
select => [ 'theclass.classification_description',
'count(me.list_uid) as list_count', 'me.list_uid', 'toplist.market',
'theclass.classification_uid'],
as => [ 'theclass.classification_description',
'list_count', 'list_uid', 'toplist.market',
'theclass.classification_uid'],
order_by => 'list_count desc',
group_by => 'list_count',
join => [qw/ toplist theclass /],
prefetch => [qw/ toplist theclass /],
});
In the select, I'm writing out the SQL for the count with the AS in
there so that it works.
The hack at
http://search.cpan.org/~danieltwc/DBIx-Class-0.07002/lib/DBIx/Class/Manual/FAQ.pod,
said there was a way to append the AS clause to the sql statement, but
I haven't been able to get it to work.
This, of course doesn't work. It fails from perl, but it's exactly
what the POD docs say.
select => [ 'theclass.classification_description', { count =>
'me.list_uid' }, \'as list_count', 'me.list_uid', 'toplist.market',
'theclass.classification_uid'],
I've solved my problem by just writing the raw sql.
I'm just wondering if the aggregate functions and the way DBIC allows
them to be created with { count => ''} syntax and made into accessors
will ever be linked to the order_by and group_by clauses?
If not, why have the { count => ''} syntax?
Thanks,
Kevin
--
Kevin Old
[EMAIL PROTECTED]
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/