/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $methodsMapping = array('Cheque' => 'CHQ', 'CB' => 'CB', 'Especes' => 'ESP'); /** @var EntityManager $em */ $em = $this->getContainer()->get("doctrine.orm.entity_manager"); $em->beginTransaction(); $output->writeln("Start loading old data ..."); /** @var DetailsWEI[] $results */ $results = $em->getRepository("BdEWeiBundle:DetailsWEI")->findAll(); $output->writeln("Create new entities ..."); foreach ($results as $detail) { if ($detail->getPlaceListeAttente() != null) { $waiting = new Waiting(); $waiting->setRank($detail->getPlaceListeAttente()); $waiting->setStudent($detail->getIdEtudiant()); $em->persist($waiting); } } $output->writeln("Start injecting in new table ..."); $em->flush(); $em->commit(); }
public function nextTicket(Payment $produit, Etudiant $student) { $qb = $this->createQueryBuilder('waiting')->select("MAX(waiting.rank)"); $ticket = new Waiting(); $ticket->setStudent($student); $ticket->setPayment($produit); try { $ticket->setRank($qb->getQuery()->getSingleScalarResult() + 1); } catch (UnexpectedResultException $e) { $ticket->setRank(1); } return $ticket; }