Skip to content

Commit f3b07bf

Browse files
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.
1 parent b7b13f0 commit f3b07bf

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

doctrine.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,11 @@ 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 ``flush()`` fails, an exception is thrown, which you can catch by wrapping
561+
the ``flush()`` method in a ``try...catch`` block.
562+
558563
Whether creating or updating objects, the workflow is always the same. In
559564
the next section, you'll see how Doctrine is smart enough to automatically
560565
issue an ``UPDATE`` query if the entity already exists in the database.

0 commit comments

Comments
 (0)