Monday, December 29, 2008

Re: Selecting users who are not friends

Understood.

So, then I'll keep looking.

...but (in the off-chance that is usable by anyone), I got what I
needed by following your suggestion. Here's what I did:

//Get the Current User's ID (from the session)
$target = $this->Session->read('User.id');

//Get IDs of all Friends of current user (as a list)
$myFriends = $this->User->FriendList->find('list', array
('fields'=>'friend_id','conditions' => array('user_id' => $target)));
//Now, add current user's ID to the myFriends array() (don't want to
add myself)
$myFriends[] = $target;
//This gets me everyone but me and my friends
$NotFriendsYet = $this->User->findAll(array('NOT' => array('id' =>
$myFriends)));


If there's a simpler solutions, please let me know - but for now I
think this works.

Thanks!
~R~

On Dec 29, 3:22 pm, "Arthur Pemberton" <pem...@gmail.com> wrote:
> On Mon, Dec 29, 2008 at 4:21 PM, WebFeathers <webfeath...@gmail.com> wrote:
>
> > Thank you Arthur - I figured I'd have to do it that way - was just
> > looking for a more elegant solution.
>
> > Thanks!
> > ~R~
>
> Keep in mind that I have only been using CakePHP for about a month
> now, someone else may have a more elegant solution. If so, I haven't
> seen it in the book however.
>
> --
> Fedora 9 : sulphur is good for the skin
> (www.pembo13.com)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: