Thanks Garet, it worked! Anyway you won't surprise if i ask again about the reason the DQL query of my first post doesn't work, exactly, why the function select() doesn't work...
Javi On Nov 23, 7:49 am, Gareth McCumskey <gmccums...@gmail.com> wrote: > I have not used Doctrine only Propel but first of all, try to avoid using > Doctrine Criteria type commands in your action. In Propel I would create a > method in my model class like: > > public static function getUserFriends($user_id) > { > $criteria = new Criteria(); > $criteria->add(self::USER1, $user_id); > $result = self::doSelect($criteria); > > $friends_array = array(); > foreach ($result as $record) > { > $friends_array[] = $record->getUser2(); > } > > return $friends_array; > > } > > In my action would be : > > $this->data = FriendReference:: getUserFriends($user_id); > > Therefore its very nicely encapsulated, 100% reusable, and if I ever need to > change the criteria of what data is returned I don't need to even touch my > action. > > > > On Mon, Nov 23, 2009 at 2:29 PM, tirengarfio <tirengar...@gmail.com> wrote: > > > On 23 nov, 06:51, Gareth McCumskey <gmccums...@gmail.com> wrote: > > > > Does it matter? > > > Maybe yes... > > > I need an array to search on it in the view. For that, i have written > > this code in the action: > > > // This fetches the friends of the user with the ID '1'. > > $this->friend_list = Doctrine::getTable('FriendReference') > > ->createQuery('a') > > ->select('a.user2') > > ->where("a.user1 LIKE ?", '1') > > ->execute(); > > > // "data" stores the friends of the user with the ID '1'. > > $this->data = $this->friend_list->toArray(); > > > And this is my code of the view: > > > // "in_array" search if a user is in the friends array. > > $a = (int)in_array($member->getId(), $data); > > > Javi > > > -- > > > You received this message because you are subscribed to the Google Groups > > "symfony users" group. > > To post to this group, send email to symfony-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > symfony-users+unsubscr...@googlegroups.com<symfony-users%2bunsubscr...@googlegroups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/symfony-users?hl=. > > -- > Gareth McCumskeyhttp://garethmccumskey.blogspot.com > twitter: @garethmcc -- You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-us...@googlegroups.com. To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=.