protected function execute(InputInterface $input, OutputInterface $output) { $this->initDoctrine($input, $output); if ($this->transactional) { $this->em->getConnection()->beginTransaction(); } try { $ret = parent::execute($input, $output); if ($ret <= 0) { if ($this->echoLog) { DoctrineHelper::enableSQLLogging('echo', $this->em); } if ($input->getOption('dry-run')) { $this->warn('DryRun: nothing is flushed'); } else { $this->em->flush(); } if ($this->transactional) { $this->em->getConnection()->commit(); } } else { if ($this->transactional) { $this->em->getConnection()->rollback(); } } } catch (\Exception $e) { if ($this->transactional) { $this->em->getConnection()->rollback(); } $this->em->close(); throw $e; } return $ret; }
public function saveFormular(array $flat) { \Psc\Doctrine\Helper::enableSQLLogging('stack', $em = $this->dc->getEntityManager()); $logger = $this->persistFromUI($flat, $this->dc->getModule()); return array('status' => TRUE, 'log' => $logger->toString(), 'context' => $this->repository->getContext(), 'sql' => \Psc\Doctrine\Helper::printSQLLog('/^(INSERT|UPDATE|DELETE)/', TRUE, $em), 'flat' => $this->getFlat()); }