[Dbix-class] help on group_by and select as?

fayland fayland at gmail.com
Fri Jul 7 11:03:10 CEST 2006


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