public function deleteClassNameAction(Request $request, Application $app) { $id_students = $request->request->get('id_studentclass'); $students = $app['dao.student']->findAllStudentByClass($id_students); $newClass = new ClassName(); $newClass->setIdClassName($id_students); $app['dao.className']->deleteclassName($newClass->getIdClassName()); $app['session']->getFlashBag()->add('danger', 'La classe a été supprimée !'); // Redirecton vers le tableau des classes return $app->redirect($app['url_generator']->generate('classeslist')); }
/** * @param ClassName $_className * Fonction de sauvegarde et de modification des classes */ public function saveClassName(ClassName $_className) { $class = array('class_name' => $_className->getClassName(), 'class_type' => $_className->getClassType(), 'class_option' => $_className->getClassOption(), 'class_year' => $_className->getClassYear(), 'description' => $_className->getDescription(), 'dt_create' => $_className->getDtCreate(), 'dt_update' => $_className->getDtUpdate()); //on modifie if ($_className->getIdClassName()) { $this->getDb()->update('className', $class, array('id_class' => $_className->getIdClassName())); } else { $this->getDb()->insert('className', $class); $_id_className = $this->getDb()->lastInsertId(); $_className->setIdClassName($_id_className); } }
public function CountStudentByClass(ClassName $className) { $_sql = "SELECT id_student FROM student WHERE id_class=?"; $_res = $this->getDb()->fetchAll($_sql, array($className->getIdClassName())); $CountStudentByClass = count($_res); return $CountStudentByClass; }