Hello,
I am very very new to using DBIx::Class -- please do forgive the naiveté of
the question - I have a question about using the order_by attribute.

Given the simple example in the CPAN docs:
http://search.cpan.org/~danieltwc/DBIx-Class-0.07002/lib/DBIx/Class/Manual/Example.pod

What would be the right syntax to get back a list of CDs ordered by the
number of tracks each has? I thought something like the following would work
but I was wrong:

sub get_cds_ordered_by_number_of_tracks {
  print "CDS ordered by the number of tracks they have\n";
  my $rs = $schema->resultset('Cd')->search(
    {},
    {
      order_by => \'tracks.count DESC',
      join     => [qw/ tracks /],
    }
  );
  while (my $cd = $rs->next) {
    print $cd->title . "\n";
  }
  print "\n";
}

Thank you very much.
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to