>From what I understand, this method extracts the ID of the followed users 
from the AUTH data right ?

Can set::extract work with the array produced when finding/viewing an user ?

Le jeudi 14 juin 2012 19:31:27 UTC+2, cricket a écrit :
>
> You could extract all of the "Following" IDs. 
>
> $following_ids = Set::extract('Folllowing/id', $this->Auth->user()); 
>
> Or: 
>
> if (in_array(Set::extract('Folllowing/id', $this->Auth->user()), 
> $some_user_id) { 
>    // already following 
> } else { 
>    ... 
> } 
>
> On Thu, Jun 14, 2012 at 10:03 AM, JonStarkwrote: 
> > I was wondering if there was a way to scan the array produced when 
> looking 
> > at an user, in the section "Follower", to match id any ID == 
> Auth.user.id, 
> > since arrays are like this : 
> > 
> > /app/Controller/UsersController.php (line 28) 
> > 
> > array( 
> >         'User' => array( 
> >                 'password' => '*****', 
> >                 'id' => '1', 
> >                 'username' => 'testuser', 
> >                 'email' => '@', 
> >                 'hash' => '', 
> >                 'created' => '2012-06-12 20:49:06' 
> >         ), 
> >         'Following' => array( 
> >                 (int) 0 => array( 
> >                         'password' => '*****', 
> >                         'id' => '2', 
> >                         'username' => 'anotertest', 
> >                         'email' => '@', 
> >                         'hash' => '', 
> >                         'created' => '2012-06-13 21:03:01', 
> >                         'UsersUser' => array( 
> >                                 'id' => '23', 
> >                                 'follower_id' => '1', 
> >                                 'following_id' => '2' 
> >                         ) 
> >                 ), 
> >                 (int) 1 => array( 
> >                         'password' => '*****', 
> >                         'id' => '3', 
> >                         'username' => 'test', 
> >                         'email' => 'test', 
> >                         'hash' => '', 
> >                         'created' => '0000-00-00 00:00:00', 
> >                         'UsersUser' => array( 
> >                                 'id' => '24', 
> >                                 'follower_id' => '1', 
> >                                 'following_id' => '3' 
> >                         ) 
> >                 ) 
> >         ), 
> >         'Follower' => array( 
> >                 (int) 0 => array( 
> >                         'password' => '*****', 
> >                         'id' => '2', 
> >                         'username' => 'anotertest', 
> >                         'email' => '@', 
> >                         'hash' => '', 
> >                         'created' => '2012-06-13 21:03:01', 
> >                         'UsersUser' => array( 
> >                                 'id' => '26', 
> >                                 'follower_id' => '2', 
> >                                 'following_id' => '1' 
> >                         ) 
> >                 ) 
> >         ) 
> > ) 
> > 
> > 
> > Wouldn't this be easier ? 
> > 
> > Le jeudi 14 juin 2012 14:40:16 UTC+2, JonStark a écrit : 
> >> 
> >> I have a table with the following fields : 
> >> 
> >> id follower_id following_id 
> >> 
> >> So when a user clicks "follow" on an other user's profile, an entry 
> like 
> >> this is created : 
> >> 
> >> 15 1 3 
> >> 
> >> meaning user with id 1 follows user with id 3. 
> >> 
> >> If user 3 follows 1, then an entry like 
> >> 
> >> 16 3 1 
> >> 
> >> is created. 
> >> 
> >> But, in order to prevent users for following many time a same user, 
> >> leading to entry such as : 
> >> 
> >> 17 3 1 
> >> 18 3 1 
> >> 19 3 1 
> >> 
> >> and so on, I want to replace "follow" by "unfollow" if the entry is 
> >> already saved. 
> >> 
> >> So my question is : how can i "scan" the table to check if an entry as 
> >> both X as follower_id AND Y as following_id ? 
> >> 
> >> Thanks a lot. 
> > 
> > -- 
> > Our newest site for the community: CakePHP Video Tutorials 
> > http://tv.cakephp.org 
> > Check out the new CakePHP Questions site http://ask.cakephp.org and 
> help 
> > others with their CakePHP related questions. 
> > 
> > 
> > To unsubscribe from this group, send email to 
> > cake-php+unsubscr...@googlegroups.com For more options, visit this 
> group at 
> > http://groups.google.com/group/cake-php 
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to