Below I'll outline what I'm actually doing to make my ManyToMany work but 
first... I'm not positive you're looking for what you're asking for.
The english version, as far as I understand it, is: *A single vote may be 
for 0..N locations AND 0..N companies*. Does this sound right? Logically it 
doesn't make much sense to me but you're designing the system so I can't 
step on those toes..


I'm using the following without issue:

/** @appropriate namespace and use statements@ **/

/**
 * @ORM\Table(name="table_left")
 * @ORM\Entity
 * @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")
 */
class Table_Left extends EntityAbstract
{
    /* ... */
    
    /**
     * @var ArrayCollection
     * @ORM\ManyToMany(targetEntity="Table_Right", mappedBy="lefts")
     */
    protected $rights;

    public function __construct()
    {
        parent::__construct();
        $this->stages = new ArrayCollection();
    }
}

/**
 * @ORM\Table(name="table_right")
 * @ORM\Entity
 * @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")
 */
class Table_Right extends EntityAbstract
{
    /* ... */
    
    /**
     * @var ArrayCollection
     * @ORM\ManyToMany(targetEntity="Table_Left", inversedBy="rights")
     * @ORM\JoinTable(name="j_table_left_right", 
joinColumns={@ORM\JoinColumn(name="right_id", referencedColumnName="id")}, 
inverseJoinColumns={@ORM\JoinColumn(name="left_id", 
referencedColumnName="id", unique=false)})
     */
    protected $lefts;

    public function __construct()
    {
        parent::__construct();
        $this->lefts = new ArrayCollection();
    }
}

I can access the related records but I cannot access the Join record (I 
shouldn't need to in this relationship)

$left = loadEntity('Table_Left', $id);
$rights = $left->rights; // Is Array collection ready for iterating...
// or
$right = loadEntity('Table_Right', $id);
$lefts = $right->lefts; // Is Array collection ready for iterating...


-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to