Note that there are some explanatory texts on larger screens.

plurals
  1. POSymfony2 Doctrine PHP Annotation for refClassRelationAlias
    primarykey
    data
    text
    <p>I have a many-to-many self-referencing non-equal relationship for one of my tables. The database tables look something like:</p> <pre><code>Node - id Node_Relationship - parent_id (FK of Node.id) - child_id (FK of Node.id) - PRIMARY KEY (parent_id, child_id) </code></pre> <p>This causes issues with Doctrine, giving a duplicate entry for that ID combination.</p> <p>This thread, <a href="http://www.doctrine-project.org/jira/browse/DC-329" rel="nofollow">http://www.doctrine-project.org/jira/browse/DC-329</a>, mentions a fix at the very bottom of using refClassRelationAlias.</p> <p>My question is, how do I implement this? I'm using the PHP annotation method to markup my classes, but they only mention using a YAML file, which I'm not currently doing.</p> <p>Can I implement this without completely redoing everything into a YAML file? If so, how?</p> <p>Thanks.</p> <p>UPDATE:</p> <p>My two fields are annotated like this:</p> <pre><code>/** * @ORM\ManyToMany(targetEntity="Module", inversedBy="children") * @ORM\JoinTable(name="module_relationships", * joinColumns={@ORM\JoinColumn(name="child_id", referencedColumnName="id")}, * inverseJoinColumns={@ORM\JoinColumn(name="parent_id", * referencedColumnName="id")} * ) */ protected $parents; /** * @ORM\ManyToMany(targetEntity="Module", mappedBy="parents") */ protected $children; </code></pre> <p>When I add something to the parent or child, I also set it's inverse. I use set and use the object's ID as the key, to avoid duplicates in the ArrayCollection.</p> <p>Did they fix the bug and I'm just doing something wrong? Or is there still a bug with a different fix. I'm using Symfony version 2.0.12.</p> <p>Thanks.</p> <p>UPDATE 2: Turns out I was creating duplicates unintentionally. Once I changed the function to actually prevent them, it seems to work just fine.</p>
    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.
 

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