I discovered the problem, I see when an exception occurs, the entitymanager will be closed. the error I was getting was because of: trigger_error($e->getMessage(), E_USER_ERROR); in my error handler, I was attempting to log $e->getMessage() into database but entity manager was closed because of the occured exception priorly in my controller. How can I fix this and restart the entity manager that is closed because of an exception?
On Tue, Jun 3, 2014 at 5:46 PM, Nima Sadjadi <[email protected]> wrote: > Product and Info entities are OneToOne. Info is the owning side. > I did this to add a new Info: > > $product = $em->find('Entities\Product', > $_POST['productId']); > if ($product !== null) { > try { > $info = new Entities\Info; > $info->setProduct($product); > $info->setFields($_POST, array('...')); > $em->persist($info); > $em->flush(); > } catch (Exception $e) { > trigger_error($e->getMessage(), E_USER_ERROR); > } > } > > when I added a another Info for the same product, of course I was getting > duplicate entry exception (because there are OneToOne) and try/catch was > working fine too. But when I did run orm:update and FK indices are added > into db, instead of duplicate entry error, I am getting "Entity is Closed" > exception and try/catch is no longer catching it and the script terminates > for exception, I tried to debug it and noticed if I remove persist line I > don't get exception any more and nothing flushed of course. I am trying to > fix it by searching google and wiki but no success yet after 1 week! stuck > on this! please help. I appreciate it. > > > -- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/d/optout.
