This topic contains 1 reply, has 2 voices, and was last updated by Mike Kudelya 7 years, 2 months ago.
- Topic
Hi,
I have this code in a controller:
12345678910111213141516171819202122232425262728293031/** @var QueryBuilder $qb */$qb = $this->getDoctrine()->getManagerForClass('CBNewAgeBundle:PanelView')->createQueryBuilder()->select('pv.id')->from('CBNewAgeBundle:PanelView', 'pv');if ($isAllSelected) {if (isset($filters['city']['value'])) {$qb->leftJoin('pv.panel','p')->leftJoin('p.addresses', 'a','WITH','a.primary=true');$qb->andWhere($qb->expr()->in('a.city', ':cities'))->setParameter('cities', $filters['city']['value']);}$forbiddenPanelViewIds = $this->getForbiddenPanelViews($offer);if (count($forbiddenPanelViewIds)>0) {$qb->andWhere($qb->expr()->notIn('pv.id', ':forbiddenIds'))->setParameter('forbiddenIds', implode(",",$forbiddenPanelViewIds));}} else {$qb->andWhere($qb->expr()->in('pv.id', $values));}$results = $qb->getQuery()->getResult();error_log('total: ' . count($results) . "\n",3,'/var/www/crm-application/app/logs/temp');and this is the equivalent sql command from the debug log:
1SELECT c0_.id AS id_0, c0_.name AS name_1, c0_.url AS url_2, c0_.panel_id AS panel_id_3, c0_.user_owner_id AS user_owner_id_4, c0_.organization_id AS organization_id_5 FROM cb_newage_panel_view c0_ LEFT JOIN cb_newage_panel c1_ ON c0_.panel_id = c1_.id LEFT JOIN cb_newage_panel_address c2_ ON c1_.id = c2_.owner_id WHERE c2_.city_id IN (?) AND c0_.id NOT IN (?) ["4,11","3"] []The problem is that they are not returning the same result. For the above values the querybuilder return only 2 records, and the normal sql select command return 6 records. Of course the second one is the correct one!!!
I cannot figure out why querybuilder returns different result for any values than the normal sql command.
If someone can help i appreciate!
PS: i tried getArrayResult() with no effect.
The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.