[Dbix-class] order_by question
africroissance
africroissance at gmail.com
Wed Jan 19 18:28:15 GMT 2011
Hello,
I am very very new to using DBIx::Class -- please do forgive the naivet=E9 =
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 =3D $schema->resultset('Cd')->search(
{},
{
order_by =3D> \'tracks.count DESC',
join =3D> [qw/ tracks /],
}
);
while (my $cd =3D $rs->next) {
print $cd->title . "\n";
}
print "\n";
}
Thank you very much.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20110119/b74=
80d50/attachment-0001.htm
More information about the DBIx-Class
mailing list