Skip to content

Instantly share code, notes, and snippets.

@codecowboy
Created July 29, 2011 16:01
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/1114113 to your computer and use it in GitHub Desktop.
Save codecowboy/1114113 to your computer and use it in GitHub Desktop.
if($request->isXmlHttpRequest()) {
if (isset($date)) {
$date = date_create_from_format('y-m-d', $date);
//remove the training session row from the db for this user
$user = $this->get('security.context')->getToken()->getUser();
$em = $this->getDoctrine()->getEntityManager();
$query = $em->createQuery('SELECT ts from GymloopDiaryBundle:TrainingSession ts
WHERE ts.user = :user AND CAST(ts.date as DATE) = :date')
->setParameter('user', $user)
->setParameter('date', $date);
$trainingSession = $query->getSingleResult();
if ($trainingSession) {
$em->remove($trainingSession);
$em->flush();
return new Response('success');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment