I don't think this answer my question.

I have something like this


    class EntityA {
        /**
         * @ORM\ManyToOne(targetEntity="EntityB", inversedBy="bar")
         */
        protected $foo;
    }
    
    class EntityB {
        /**
         * @ORM\OneToMany(targetEntity="EntityA", mappedBy="foo")
         */
        protected $bar;
        
        /**
         * @ORM\Column(type="string", length=123)
         */
        protected $baz;
    }
    
    

I would like to do make a query returning say all EntityA objects whose 
foo->baz is eual to a given string.
I was wondering if there's some mechanism to abstract the join, something 
like passing ["foo.baz" => "test"] or something.

And using some kind of system where I can add to the query later on Eg: 
using QueryBuilder or Criteria.



On Friday, June 5, 2020 at 12:43:49 PM UTC+2, Marco Pivetta wrote:
>
> This is called "arbitrary joins" in DQL:
>
> ```php
> <?php
> $query = $em->createQuery('SELECT u FROM User u JOIN Blacklist b WITH 
> u.email = b.email');
> ```
>
> See 
> https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/dql-doctrine-query-language.html
>
> Marco Pivetta 
>
> http://twitter.com/Ocramius      
>
> http://ocramius.github.com/
>
>
> On Fri, Jun 5, 2020 at 12:41 PM Mattia Basaglia <[email protected] 
> <javascript:>> wrote:
>
>> Let's say I have two entity classes, let's call them EntityA and EntityB.
>> In EnityA I have a ManyToOne or something to EntityB.
>>
>> Can I create a query to get EnrityA objects based on a condition 
>> referencing their related EntityB without having to manually specify joins?
>>
>> -- 
>> 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] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/doctrine-user/1280df0e-b8fb-4391-a15c-5117e3ff3c5do%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/doctrine-user/1280df0e-b8fb-4391-a15c-5117e3ff3c5do%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/doctrine-user/413a03e9-f1fe-4475-ac84-ef00db055e86o%40googlegroups.com.

Reply via email to