Symfony 使用 OneToMany 的标准

MF

有没有办法根据控制器中的条件从多方面获取项目?

    /**
 * One Content has Many Files.
 * @ORM\OneToMany(targetEntity="IntersaxoniaBackendBundle\Entity\Content", mappedBy="sidContents", cascade={"persist", "remove"}, orphanRemoval=true)
 * @ORM\JoinColumn(nullable=true)
 */
private $contents;

无法从许多内容中访问 do:

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

就像是:

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

我不明白你到底想达到什么目的。什么是 $dsid,你在哪个班级private $contents但看起来您需要获取content具有$dsidid类对象的站点

我认为这样做是不可能的。您只能使用findBy()方法通过拥有侧关联来加载。所以这个扫描是一个解决方案:

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章