[Dbix-class] Selecting max() of count()

Iain Hubbard iain.hubbard at gmgrd.co.uk
Fri Aug 1 13:00:08 BST 2008


On Fri, 2008-08-01 at 12:06 +0200, BUNK (Jacob Bunk Nielsen) wrote:
> Perhaps, but it also ignores any mentioning of 'count'. This doesn't
> seem logical to me. Do you have any idea why it ignores count?

The max is obviously causing a problem, how about a different approach?

** untested **
my $basket = $schema->resultset('shop.basket')->search(
     {basket_id => [1, 2]},
     {
      select => [ \'COUNT(me.item_id) as c' ],
      as => ['c'], 
      order_by => ['c desc'],
      'group_by' => 'me.basket_id'
     }
)->single;
print $basket->get_column('c'), "\n";
** untested **

Should get you the max count, but the method may not be to your liking.

Iain 
--------------------------------------------------------
GMG Regional Digital is part of the Guardian Media Group plc.




CONFIDENTIALITY NOTICE. The information contained in this e-mail is intended only for dbix-class at lists.scsys.co.uk. It may contain privileged and confidential information that is exempt from disclosure by law and if you are not an intended recipient, you must not copy, distribute or take any action in reliance on it. If you have received this e-mail in error, you may notify us by telephone on 44 (0)161 832 7200. E-mail transmission cannot be guaranteed to be secure or error-free. The sender (iain.hubbard at gmgrd.co.uk) therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. If verification is required please request a hard-copy version.

Scanned by MailDefender - managed email security from intY - www.maildefender.net



More information about the DBIx-Class mailing list