Ahh, I get it, and this is painful to solve:

For every condition you also need a JOIN. You have 2 conditions, so you'll need 
2 JOINs:

    SELECT p FROM Module\Entity\Product p
    JOIN p.subcategories s1
    JOIN p.subcategories s2
    WHERE s1.id = 1 AND s2.id = 3

If you have 3 conditions, you'll need 3 JOINs:

    SELECT p FROM Module\Entity\Product p
    JOIN p.subcategories s1
    JOIN p.subcategories s2
    JOIN p.subcategories s3
    WHERE s1.id = 1 AND s2.id = 3 AND s3.id = 5

Etc... You can see how this will impact performance drastically if the number 
of conditions increases.

If you don't understand why the extra JOINs are needed, I'll be happy to 
explain!

-- 
Jasper N. Brouwer
(@jaspernbrouwer)


On 6 Feb 2014, at 20:03, zarloc <[email protected]> wrote:

> OR operator find the products that contain subcategory 1 + product hat 
> contain subcategory 3
> 
> but i have find the products that contain 1 and 3
> 
> product
>    |
>    ---------- subcategory -> red
>    |
>    ---------- subcategory -> circle
> 
> if i use OR operator I find  also product-> red  AND product -> circle but i 
> exclude this from results

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to