Created
July 29, 2011 16:01
-
-
Save codecowboy/1114113 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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