Doctrine 2 documentation states that:
Removing an association between two entities is similarly
straight-forward. There are two strategies to do so, by key and by
element.
What’s the meaning of “by key”? It’s the id field of the related entity or simply the position of the related entity in the collection? For example here $ithComment is used (that is the position of the comment):
// Remove by Key
$user->getComments()->remove($ithComment);
$comment->setAuthor(null);
Its the position of the related entity in the collection. On inspecting ArrayCollection..
You can see no reference to the collection items identifier is used.