*I want to join table on the basis of two colums.
I have a dql join query like this-
$qb=$this->em->createQueryBuilder();
$from = 'Entities\User u';
$qb->select('u.id User_Id, u.name User_Name, evtvst.event Event_id,evt.name eventname, cty.name City,ctry.name Country')
->add('from', $from)
->join('Entities\EventVisitor','evtvst','with','u.id=evtvst.user')
->join('Entities\Event','evt','with','evt.id=evtvst.event')...........#
->join('Entities\Country','ctry','with','evt.country=ctry.id')
->join('Entities\City','cty','with','evt.city=cty.id')
->where('evtvst.user=?1')
->setParameter(1,$_GET["user"])
->setFirstResult($i)
->setMaxResults($max_result)
->distinct();
$query = $qb->getQuery();
$query->getSQl();
$results = $query->getResult();
now i am add one more condition to the # marked colum like this-
->join('Entities\Event','evt','with','evt.id=evtvst.event', and 'evt.eventEdition=evtvst.edition')
But it is not working. pls tell a way to do it.
Ok now i find out a solution for this
You just have to change the alias of the table while applying join second time. I have done like this
->join('Entities\EventVisitor','evtvst','with','u.id=evtvst.user')
->join('Entities\Event','evt','with','evt.id=evtvst.event')
->join('Entities\Event','evt1','with','evt1.eventEdition=evtvst.edition')
->join('Entities\Country','ctry','with','evt.country=ctry.id')
->join('Entities\City','cty','with','evt.city=cty.id')
->where('evtvst.user=?1')
and its working fine.