Doctrine orm Symfony从OneToMany获得标准

Doctrine orm Symfony从OneToMany获得标准,doctrine-orm,symfony-3.4,Doctrine Orm,Symfony 3.4,是否有一种方法可以通过控制器中的条件从多个方面获取项目 /** * One Content has Many Files. * @ORM\OneToMany(targetEntity="IntersaxoniaBackendBundle\Entity\Content", mappedBy="sidContents", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\JoinColumn(nullable=true)

是否有一种方法可以通过控制器中的条件从多个方面获取项目

    /**
 * One Content has Many Files.
 * @ORM\OneToMany(targetEntity="IntersaxoniaBackendBundle\Entity\Content", mappedBy="sidContents", cascade={"persist", "remove"}, orphanRemoval=true)
 * @ORM\JoinColumn(nullable=true)
 */
private $contents;
无法从许多内容访问did:

$side = $em->getRepository('XYBundle:Side')->findBy(
            array('dsid' => $dsid)
        );
比如:

$side = $em->getRepository('XYBundle:Side')->getContents()->findBy(
            array('dsid' => $dsid)
        );

我看不出你到底想达到什么目的。什么是$dsid,在哪个类中有
私有$contents
。但看起来您需要使用
$dsid
id获取具有类
内容的对象的站点

我认为这样做是不可能的。您只能使用
findBy()
方法通过拥有端关联进行加载。因此,此扫描可能是一个解决方案:

$content = $em->getRepository('XYBundle:Content')->findBy(
    array('side' => $site->getId())
);
$side = $content->getSide();