Skip to content

Instantly share code, notes, and snippets.

@codecowboy
Created July 27, 2011 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecowboy/1109764 to your computer and use it in GitHub Desktop.
Save codecowboy/1109764 to your computer and use it in GitHub Desktop.
catch EM error
if (isset($date)) {
$trainingSession = new TrainingSession();
$user = $this->get('security.context')->getToken()->getUser();
$trainingSession->setUser($user);
$date = date_create_from_format('d/m/y', $date);
$trainingSession->setDate($date);
$trainingSession->setStatus('pending');
$trainingSession->setType('gym');
$em = $this->getDoctrine()->getEntityManager();
$em->persist($trainingSession);
try {
$em->flush();
return new Response('yay');
} catch(\Exception $e) {
return new Response('error'.$e->getMessage());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment