0
私はSymfony 3.2を使用しています。私はSite
というエンティティを持っていて、それにはIndication
という別のエンティティに対するOneToMany関係が含まれています。 symfony/doctrineでの1つのNOTToMany関係のクエリ
class Site
{
/**
* @ORM\OneToMany(targetEntity="IhkBundle\Entity\Indication", mappedBy="site")
*/
private $indications;
}
class Indication
{
/**
* @ORM\ManyToOne(targetEntity="IhkBundle\Entity\Site", inversedBy="indications")
* @ORM\JoinColumn(name="site_id", referencedColumnName="id")
*/
private $site;
}
私はIndications
が利用可能なすべてのsites
を照会します。私は何をするべきかわからないArrayCollectionしか得られません。
$sites = $repository->findAll();
foreach ($sites as $site) {
$site->getIndications();
}
また、this answerのようにqueryBuilderを使用しようとしました。
次のエラーがスローされます$query = $repository->createQueryBuilder('s');
$result = $query->where('s.indications IS NOT NULL')
->getQuery()
->getResult();
:
[Semantical Error] line 0, col 46 near 'indications IS': Error: Invalid PathExpression. StateFieldPathExpression or SingleValuedAssociationField expected.