Hi, i solved merging the collections (Doctrine merge() method):

        public static function getAmigos($id)
  {

  $q1 = Doctrine_Query::create()
      ->from('Usuario u')
      ->leftJoin('u.AmigoUsuario a ON u.id = a.user2')
      ->where("a.user1 = ?", $id)
      ->andWhere("a.estado LIKE ?", 1)
      ->execute() ;

  $q2 = Doctrine_Query::create()
      ->from('Usuario u')
      ->leftJoin('u.AmigoUsuario a ON u.id = a.user1')
      ->where("a.user2 = ?", $id)
      ->andWhere("a.estado LIKE ?", 1)
      ->execute();

  $q1->merge($q2);

        return $q1;

  }

Bye


Javi


On Dec 3, 3:51 pm, tirengarfio <[email protected]> wrote:
> Sorry, i was wrong i also have error with the getters when i have only
> one query...:)
>
> So the question again: how do you merge the resulting objects of two
> queries?
>
> Javi
>
> On Dec 3, 3:28 pm, tirengarfio <[email protected]> wrote:
>
> > Hi,
>
> > i have these two queries below and i want to merge the resulting
> > objects, but i can't.
>
> >  public static function getAmigos($id)
> > {
> >     $q1 = Doctrine_Query::create()
> >       ->from('Usuario u')
> >       ->leftJoin('u.AmigoUsuario a ON u.id = a.user1')
> >       ->where("a.user2 LIKE ?", $id)
> >       ->andWhere("a.estado LIKE ?", 1)
> >       ->execute();
>
> >     $q2 = Doctrine_Query::create()
> >       ->from('Usuario u')
> >       ->leftJoin('u.AmigoUsuario a ON u.id = a.user2')
> >       ->where("a.user1 LIKE ?", $id)
> >       ->andWhere("a.estado LIKE ?", 1)
> >       ->execute();
>
> >      $array_q1 = $q1->toArray();
>
> >     $array_q2 = $q2->toArray();
>
> >     $q = array_merge($array_q1, $array_q2);
>
> >     return $q;
>
> >   }
>
> > As you can see I have tried it with array_merge() but i get errors
> > with the getters because the resulting objects are not considered as
> > "objects" anymore.
>
> > No problem if use only one query, i mean this:
>
> >  public static function getAmigos($id)
> >         {
>
> >     $q1 = Doctrine_Query::create()
> >       ->from('Usuario u')
> >       ->leftJoin('u.AmigoUsuario a ON u.id = a.user1')
> >       ->where("a.user2 LIKE ?", $id)
> >       ->andWhere("a.estado LIKE ?", 1)
> >       ->execute();
>
> >     $array_q1 = $q1->toArray();
>
> >     return $q1;
>
> >   }
>
> > How would you do it?
>
> > Bye
>
> > Javi

--

You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en.


Reply via email to