I have a question about DQL query.
I have these tables: 'orders', 'orders_kitchen', 'orders_institution' and 'variants'.
From the table 'variants', I get order IDs that have already been made offers.
$orders = $em->createQuery("SELECT o
FROM AppBundle:Orders o
JOIN AppBundle:OrdersInstitution oi
WHERE oi.idInstittuion = :institution AND o.idorder = oi.idOrder AND o.finalDeal IS NULL
ORDER BY o.idorder DESC")
->setParameter("institution",$institution)->getResult();
When a customer leaves the order, he may proceed in three ways:
I need to find all orders that have not selected any one institution, and none of the types of cuisines, or at least one of the kitchen works with the institution (this can be an array).
And I don't want to choose orders whose ID is in the table 'variants'.
You can try it with SQL something like (DQL doesnt performe well with lot of joins) :
$sql = 'SELECT * FROM Orders o JOIN
(SELECT o1.id FROM Orders o1 WHERE o1.cuisine IS NULL OR o1.institution IS NULL) o1 JOIN
(SELECT * FROM Orders o2 INNER JOIN Cuisine c ON c.insitution_id = '.$institution_id.') o2 JOIN (your query);';
Something like this should do it, not expert in SQL i usually end up trying until i get it !
I dont think its correct tho but at least its a start :p