Skip to content

Commit 904b3f6

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: Update associations.rst
2 parents 3f63819 + 171e0ed commit 904b3f6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

doctrine/associations.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,15 @@ also generated a ``removeProduct()`` method::
581581
Thanks to this, if you call ``$category->removeProduct($product)``, the ``category_id``
582582
on that ``Product`` will be set to ``null`` in the database.
583583

584+
.. warning::
585+
586+
Please be aware that the inverse side could be associated with a large amount of records.
587+
I.e. there could be a large amount of products with the same category.
588+
In this case ``$this->products->contains($product)`` could lead to unwanted database
589+
requests and very high memory consumption with the risk of hard to debug "Out of memory" errors.
590+
591+
So make sure if you need an inverse side and check if the generated code could lead to such issues.
592+
584593
But, instead of setting the ``category_id`` to null, what if you want the ``Product``
585594
to be *deleted* if it becomes "orphaned" (i.e. without a ``Category``)? To choose
586595
that behavior, use the `orphanRemoval`_ option inside ``Category``:

0 commit comments

Comments
 (0)