[Solar-talk] How can i implement ordering on a
_belongsToor_hasMany relationship
Kilbride, James P.
James.Kilbride at gd-ais.com
Tue Feb 19 23:20:05 CST 2008
Paul's suggestion only covers a single way of doing that. If one
business report requires it be sorted one way and another a different
way paul's method doesn't allow me to change it, unless perhaps I
redefine the has many on the fly? I think I can do that right?
James Kilbride
-----Original Message-----
From: solar-talk-bounces at lists.solarphp.com
[mailto:solar-talk-bounces at lists.solarphp.com] On Behalf Of Antti
Holvikari
Sent: Tuesday, February 19, 2008 9:52 AM
To: solar-talk at lists.solarphp.com
Subject: Re: [Solar-talk] How can i implement ordering on a
_belongsToor_hasMany relationship
On Feb 19, 2008 4:11 PM, Kilbride, James P. <James.Kilbride at gd-ais.com>
wrote:
>
>
> Not exactly Raymond. More looking to order them by a column in the
> employees table, such as something like employee name. Say I'm doing a
> hierarchal set of drop downs. The first drop down has the departments
> ordered by name. Not hard, I just put that order by in my fetchall.
> But now when I'm building the second dimension of my arrays I want to
> order the employees for that department by their names. I can do it by
> calling a fetch on the employees table based on the department id, for
> example, but then I'm not using the fact that there is a relationship
> on the department model at all. I've completely ignored that fact.
> What I want is some way to pass the relationship a series of
> parameters, like a fetch, when I call it so it can reorder them for me
> if possible. I can of course do the sorting after i get the results
> from the database using php's sort but it would certainly be nicer to
get the order from the DB.
Then it looks like what Paul suggested would work for you. That way
every time you fetch data from the related table the results get ordered
by the order you gave when setting up the relation.
--
Antti Holvikari <http://anttih.com>
_______________________________________________
Solar-talk mailing list
Solar-talk at lists.solarphp.com
http://mailman-mail3.webfaction.com/listinfo/solar-talk
More information about the Solar-talk
mailing list