Skip to content

Instantly share code, notes, and snippets.

@morontt
Created November 19, 2015 10:09
Show Gist options
  • Save morontt/c57801682e34eadc7846 to your computer and use it in GitHub Desktop.
Save morontt/c57801682e34eadc7846 to your computer and use it in GitHub Desktop.
<?php
use App\Alien;
use Doctrine\DBAL\DBALException;
$entity = new Alien();
try {
$this->em->persist($entity);
$this->em->flush();
} catch (DBALException $e) {
if (!$this->em->isOpen()) {
$this->doctrine->resetManager();
$this->em = $this->doctrine->getManager();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment