[Dbix-class] help on group_by and select as?
Chris Lock
CLock at EU.Advertising.com
Fri Jul 7 12:09:25 CEST 2006
I wanted to do something similar I was told it cant be done (as yet)
because of the way DISTINCT works. But he also tells me that
sub-selects will be coming in 08 which may fix things.
------------------------------
Message: 5
Date: Fri, 07 Jul 2006 09:03:10 +0000
From: fayland <fayland at gmail.com>
Subject: [Dbix-class] help on group_by and select as?
To: dbix-class at lists.rawmode.org
Message-ID: <44AE234E.1070809 at gmail.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
mmm, I have some code like this:
my $it = $dbic_data->resultset('table_name')->search( {
want => $want,
}, {
select => [ 'a', 'b', { max => 'c' } ],
as => [ 'a', 'b', 'max_cid' ],
group_by => [qw/ a b /],
order_by => 'max_cid DESC',
page => 1,
rows => 10
} );
debug info shows:
DBIx::Class::ResultSet::all(): Error executing 'SELECT a, b, MAX( c )
FROM table_name me WHERE ( want = ? ) GROUP BY a, b ORDER BY max_cid
DESC LIMIT 10': Unknown column 'max_cid' in 'order clause' at
seems as => is not working? my code is anything wrong?
When I comment the "order_by => 'max_cid DESC', it complains like this:
|
DBIx::Class::ResultSet::pager(): Error executing 'SELECT COUNT(
DISTINCT( a, b ) ) FROM table_name me WHERE ( want = ? )': Operand
should contain 1 column(s) at
I don't know why? mm, I tried |0.06999_05
<http://search.cpan.org/%7Ejguenther/DBIx-Class-0.06999_05/> and
0.06003, both no luck.
Thanks in advanced.
--
Fayland Lam // http://www.fayland.org/
More information about the Dbix-class
mailing list