Re: [CDBI] order by a foreign key

[prev] [thread] [next] [Date index for 2005/08/16]

From: Hartmaier Alexander
Subject: Re: [CDBI] order by a foreign key
Date: 16:00 on 16 Aug 2005
This is a MIME-formatted message.  If you see this text it means that your
E-mail software does not support MIME-formatted messages.

--===============1002787667==
Content-class: urn:content-classes:message
Content-Type: multipart/signed; protocol="application/x-pkcs7-signature";
	micalg=SHA1;
	boundary="=_pbote1.srv.dsh.at-1364-1124208035-0001-2"

This is a MIME-formatted message.  If you see this text it means that your
E-mail software does not support MIME-formatted messages.

--=_pbote1.srv.dsh.at-1364-1124208035-0001-2
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Use Class::DBI::Sweet ;-)
@array =3D My::Class->retrieve_all({ fieldname =3D> 'value'});

-Alex


> -----Urspr=FCngliche Nachricht-----
> Von: classdbi-bounces@xxxxx.xxxxxxxxxxxxxxxx.xxx [mailto:classdbi-
> bounces@xxxxx.xxxxxxxxxxxxxxxx.xxx] Im Auftrag von Randal L. Schwartz
> Gesendet: Dienstag, 16. August 2005 17:48
> An: Marcello
> Cc: classdbi@xxxxx.xxxxxxxxxxxxxxxx.xxx
> Betreff: Re: [CDBI] order by a foreign key
>=20
> >>>>> "Marcello" =3D=3D Marcello  <m.romani@xxxxxxxx.xx> writes:
>=20
> Marcello> I have two tables, 'cd' and 'artist', whose model classes =
are
> Marcello> MyApp::Cd and MyApp::Artist.
>=20
> Marcello> MyApp::Artist is stringified as 'name'
>=20
> Marcello> The relationship is:
> Marcello> MyApp:Cd->has_a( artist =3D> MyApp::Artist );
>=20
> Marcello> MyApp::Cd uses Class::DBI::Plugin::RetrieveAll, so I can =
say:
> Marcello> my @cds =3D MyApp::Cd->retrieve_all_sorted_by( $order ); # =
e.g.
> title ASC
>=20
> Marcello> And now to the point:
> Marcello> if $order =3D=3D 'artist' the @cds list gets ordered by the =
artist
> *id*,
> Marcello> not by the artist name.
>=20
> Marcello> What I would like to obtain is a list ordered by the foreign
> class's
> Marcello> 'stringify' column.
>=20
> Dunno how to do it with that plugin, but using this little trick
> I came across one day...
>=20
> my @ordered_cds =3D map $_->[0],
>   sort { $a->[1] cmp $b->[1] }
>   map [$_, $_->artist->stringify], MyApp::Cd->retrive_all;
>=20
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
> 0095
> <merlyn@xxxxxxxxxx.xxx> <URL:http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl
> training!
>=20
> _______________________________________________
> ClassDBI mailing list
> ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
> http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

--=_pbote1.srv.dsh.at-1364-1124208035-0001-2
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
	filename="smime.p7s"

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIISkjCCApow
ggIDoAMCAQICASQwDQYJKoZIhvcNAQEEBQAwcTELMAkGA1UEBhMCREUxHDAaBgNVBAoTE0RldXRz
Y2hlIFRlbGVrb20gQUcxHzAdBgNVBAsTFlQtVGVsZVNlYyBUcnVzdCBDZW50ZXIxIzAhBgNVBAMT
GkRldXRzY2hlIFRlbGVrb20gUm9vdCBDQSAxMB4XDTk5MDcwOTExMzQwMFoXDTE5MDcwOTIzNTkw
MFowcTELMAkGA1UEBhMCREUxHDAaBgNVBAoTE0RldXRzY2hlIFRlbGVrb20gQUcxHzAdBgNVBAsT
FlQtVGVsZVNlYyBUcnVzdCBDZW50ZXIxIzAhBgNVBAMTGkRldXRzY2hlIFRlbGVrb20gUm9vdCBD
QSAxMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQ3ZsMoBdERA+vIUBzZ1bwPmloEbrZN/KB
rsMkrGmhzfymGFVW/4ufMsHb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BJbnRlcm5hdGlvbmFsIEdtYkgxJTAjBgNVBAsTHFQtU3lzdGVt
cyBJbnRlcm5hdGlvbmFsIEdtYkgxHTAbBgNVBAMTFFQtU3lzdGVtcyBDb21wYW55IENBAgJHFjCB
kwYLKoZIhvcNAQkQAgsxgYOggYAwejELMAkGA1UEBhMCREUxJTAjBgNVBAoTHFQtU3lzdGVtcyBJ
bnRlcm5hdGlvbmFsIEdtYkgxJTAjBgNVBAsTHFQtU3lzdGVtcyBJbnRlcm5hdGlvbmFsIEdtYkgx
HTAbBgNVBAMTFFQtU3lzdGVtcyBDb21wYW55IENBAgJHFjANBgkqhkiG9w0BAQEFAASBgBO2BhNM
CFq6cd6gM72FIQtUmZMqNwywcdbdW+214goEoqhUEV01HdabPeRXOXfG7ixhbZ8aSGVpU0mommkL
rgAQn8ew2eV8CvORCYrrz/avSrjPeYEaD+gDYIuybvfSNKr+FgufjI0Yx/5vX8LpcdqGf+1pTXO0
7urViDdgkJDjAAAAAAAA

--=_pbote1.srv.dsh.at-1364-1124208035-0001-2--


--===============1002787667==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

--===============1002787667==--

[CDBI] order by a foreign key
Marcello 15:34 on 16 Aug 2005

Re: [CDBI] order by a foreign key
merlyn (Randal L. Schwartz) 15:48 on 16 Aug 2005

Re: [CDBI] order by a foreign key
Marcello 16:44 on 16 Aug 2005

Re: [CDBI] order by a foreign key
Hartmaier Alexander 16:00 on 16 Aug 2005

Re: [CDBI] order by a foreign key
Matt S Trout 16:08 on 16 Aug 2005

Re: [CDBI] order by a foreign key
Marcello 16:47 on 16 Aug 2005

Re: [CDBI] order by a foreign key
Matt S Trout 17:04 on 16 Aug 2005

Re: [CDBI] order by a foreign key
Marcello 07:33 on 17 Aug 2005

Generated at 13:17 on 19 Aug 2005 by mariachi v0.52