Otóż mam sobie dwie encje połączone relacją dwukierunkową many-to-many w ten sposób:
/** * Tag * * @ORM\Table(name="tag") * @ORM\Entity(repositoryClass="AppBundle\Repository\TagRepository") */ class Tag { . . . /** * @ORM\ManyToMany(targetEntity="Note", mappedBy="tags") */ private $notes;
/** * Note * * @ORM\Table(name="note") * @ORM\Entity(repositoryClass="AppBundle\Repository\NoteRepository") */ class Note { . . . /** * @ORM\ManyToMany(targetEntity="Tag", inversedBy="notes", cascade={"persist"}) * @ORM\JoinTable(name="notes_tags") */ private $tags;
Chciałbym stworzyć sobie proste wyszukiwanie po tagach, więc piszę sobie:
$query->andWhere('n.tags = :tag')->setParameter('tag', 6); }
i otrzymuję błąd:
Cytat
[Semantical Error] line 0, col 46 near 'tags = :tag ORDER': Error: Invalid PathExpression. StateFieldPathExpression or SingleValuedAssociationField expected.
Co i dlaczego robię źle? Z góry dziękuję za pomoc.