Php 如何组织一个不寻常的联系一个理论2

Php 如何组织一个不寻常的联系一个理论2,php,doctrine,Php,Doctrine,有一个实体需要在其中实现OneToOne关系,但问题是它们之间的连接是由非关键字段执行的,并且存在多个字段    class MyEntityOne     {                  protected $ id;         protected $ pole1;         protected $ pole2;         protected $ pole3;         protected $ myEntytyTwo;               }     

有一个实体需要在其中实现
OneToOne
关系,但问题是它们之间的连接是由非关键字段执行的,并且存在多个字段

    class MyEntityOne
    {
        
        protected $ id;
        protected $ pole1;
        protected $ pole2;
        protected $ pole3;
        protected $ myEntytyTwo;
         
    }
    
    class MyEntityTwo
    {
        protected $ pole1;
        protected $ pole2;
        protected $ pole3;
        protected $ pole4;
        protected $ pole5;
        protected $ myEntytyOne;
    }
它们之间的关系是:

选择*从MyEntityOne到左连接MyEntityTwo T ON(O.pole1=T.pole1和O.pole2=T.pole2和O.pole2=T.pole2和T.pole5=1)


我在文档中没有找到如何更好地实现此连接,如果有任何想法,我将不胜感激。

这应该可以解决问题

        /** @var EntityManagerInterface */
        $em = $this->getDoctrine()->getManager();

        $qb = $em->createQueryBuilder();
        $qb->select('o')
            ->from('App\Entity\MyEntityOne', 'o')
            ->join('App\Entity\MyEntityTwo', 't')
            ->where(
                'o.pole1 = t.pole1',
                'o.pole2 = t.pole2',
                'o.pole3 = t.pole3',
                't.pole5 = 1'
            )
            ->getQuery()
            ->getResult()
        ;

您要归档的是从pole1、pole2和pole3相同的表中获取实体吗?或者它们实际上是用@OneToOne映射的?@B0re如果pole1,pole2,pole3满足并且pole5=1,我需要得到pole4谢谢,这正是我需要的,但我有一个问题如何在
实体中描述它