Reputation: 1828
Using Doctrine I am trying to check if flush()
is successful.
before my ORM days I used to do if ( $query->execute() ) {}
Since flush()
returns void, I am not convinced that using try catch
would solve the problem like suggested here ? Would it ?
If not, is there a way to achieve something similar ?
Upvotes: 4
Views: 7088
Reputation: 5881
Under the hood, PDO will throw an exception if executing the query fails. Doctrine will not silence this exception (it will wrap it, but rethrow). So just making sure no exception is thrown is enough to check if everything was executed successfully.
Upvotes: 8
Reputation: 12
if you want to know if an entity has been flushed, you can make use doctrine event listener (https://symfony.com/doc/3.0/doctrine/event_listeners_subscribers.html)
the help you to make an action automatically after a persist event
Upvotes: -2