[Solar-talk] How can i implement ordering on a _belongsTo
or_hasMany relationship
Antti Holvikari
anttih at gmail.com
Fri Feb 15 14:24:23 CST 2008
On Fri, Feb 15, 2008 at 10:08 PM, Kilbride, James P.
<James.Kilbride at gd-ais.com> wrote:
> Antti,
>
> That looks like you are duplicating the relationship defined in the
> model in that fetchRelated call when you do the department_id =
> someValue.
Yes I know, that sucks :-(.
I have a department record, from that record I want to pull
> all it's children records which have some column equal to something. Say
> I have a user and a conversation table where users have many
> conversations and each conversation has many users(basically which users
> were in the conversation). The conversation to user relationship is
> called users.
>
> I've pulled out a set of conversations.
>
> $conversations = $convers->fetchAll(someStuff);
>
> and now I want only the inactive users on those conversations:
>
> foreach($conversations as $conversation) {
> $allUsers = $conversation->users;
> $inactiveUsers = $conversation->fetchRelated(array( 'where' =>
> "active = 0" ), 'users'); //doesn't work.
> }
>
> How do I get all the inactive only users for that given record in the
> conversation list?
I don't think I have a better answer, maybe Paul has some ideas?
I think I would just create a new method in my record object and put
the logic there.
--
Antti Holvikari <http://anttih.com>
More information about the Solar-talk
mailing list