Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't use JOIN with related entities in doctrine2
    primarykey
    data
    text
    <p>I was <a href="http://docs.doctrine-project.org/en/latest/reference/dql-doctrine-query-language.html#joins" rel="nofollow">guided by this</a>, and I can't understand what's going wrong. </p> <p>My entities:</p> <pre><code>/** * @ORM\Entity * @ORM\Table(name="term") */ class Term { /** * @ORM\Column(type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @ORM\OneToMany(targetEntity="Description", mappedBy="term") **/ private $description; //.... } /** * @ORM\Entity * @ORM\Table(name="description") */ class Description { /** * @ORM\Column(type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @Orm\ManyToOne(targetEntity="term", inversedBy="description") * @Orm\JoinColumn(name="term_id", referencedColumnName="id") **/ private $term; /** * @ORM\Column(type="string", length=8) */ private $normativity; //... } </code></pre> <p>I need to get terms and filter terms descriptions by one of it fields (normativity in example).</p> <p>I tried this:</p> <pre><code>$query = $this-&gt;getDoctrine()-&gt;getEntityManager() -&gt;createQuery(" SELECT term, desc FROM myTerminologyBundle:Term term JOIN term.description desc WHERE term.word LIKE :r_word' and desc.normativity IN :norm" )-&gt;setParameter('r_word', '%'.$word.'%')-&gt;setParameter('norm', array()); </code></pre> <p>and I get the following exceptions:</p> <blockquote> <p>[Syntax Error] line 0, col 30: Error: Expected IdentificationVariable | ScalarExpression | AggregateExpression | FunctionDeclaration | PartialObjectExpression | "(" Subselect ")" | CaseExpression, got 'desc'</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload