[Solar-talk] How can i implement ordering on a _belongsTo
or_hasMany relationship
Antti Holvikari
anttih at gmail.com
Tue Feb 19 08:52:18 CST 2008
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>
More information about the Solar-talk
mailing list