-2

hello i have 2 many to one relation in database and use sql query is ok but can`t convert query mysql to dql or querybuilder please help me

SELECT * 
FROM `resturant`
LEFT JOIN `food`
    ON `resturant`.`id` = `food`.`resturant_id` 
WHERE `food`.`name`LIKE "%pizza%" 
GROUP BY `resturant`.`name`
Michael Mairegger
  • 6,833
  • 28
  • 41
Kaveh Yzd
  • 119
  • 1
  • 12
  • 1
    What is causing you troubles? See http://doctrine-orm.readthedocs.io/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html – Rvanlaak May 25 '16 at 09:07

1 Answers1

0

Assuming your Restaurant entity is linked to the Food entity through the attribute $foods:

$this->createQueryBuilder('restaurant')
    ->leftJoin('restaurant.foods', 'food')
    ->where('food.name LIKE %pizza%')
    ->groupBy('restaurant.name')
    ->getQuery()->getResult();
Terenoth
  • 2,458
  • 1
  • 14
  • 21