Skip to content

Commit bb12a80

Browse files
committed
minor #6894 Explain what happens if flush() fails (ThomasLandauer)
This PR was merged into the 2.7 branch. Discussion ---------- Explain what happens if `flush()` fails It should be mentioned _somewhere_ in this chapter, how to verify that the entity has really been persisted. What's the best practice here? try...catch? Or (for INSERT) check if $entity->getId() does exist? => Please expand on that. Also, you could list all possible types of exceptions explicitly. Commits ------- 460b74a Integrated improvement by javiereguiluz f3b07bf Explain what happens if `flush()` fails
2 parents bf7c94d + 460b74a commit bb12a80

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

doctrine.rst

+6
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,12 @@ Take a look at the previous example in more detail:
555555
``Product`` objects and then subsequently call ``flush()``, Doctrine will
556556
execute 100 ``INSERT`` queries using a single prepared statement object.
557557

558+
.. note::
559+
560+
If the ``flush()`` call fails, a ``Doctrine\ORM\ORMException`` exception
561+
is thrown, which you can catch by wrapping the ``flush()`` method in a
562+
``try...catch`` block.
563+
558564
Whether creating or updating objects, the workflow is always the same. In
559565
the next section, you'll see how Doctrine is smart enough to automatically
560566
issue an ``UPDATE`` query if the entity already exists in the database.

0 commit comments

Comments
 (0)