VK
Size: a a a
BY
BY
MM
AD
q
$file = new File();
$file->setName($filename);
$file->setSize($uploadedFile->getSize());
$this->em->getConnection()->beginTransaction();
$this->em->persist($file);
$this->em->flush();
try {
$uploadedFile->move($this->getTargetDirectory(), $file->getId());
$this->em->getConnection()->commit();
} catch (FileException $e) {
$this->em->getConnection()->rollBack();
throw $e;
}
VS
$file = new File();
$file->setName($filename);
$file->setSize($uploadedFile->getSize());
$this->em->getConnection()->beginTransaction();
$this->em->persist($file);
$this->em->flush();
try {
$uploadedFile->move($this->getTargetDirectory(), $file->getId());
$this->em->getConnection()->commit();
} catch (FileException $e) {
$this->em->getConnection()->rollBack();
throw $e;
}
ВМ
q
q
public function beginTransaction() {
$connection = $this->getWrappedConnection();
++$this->transactionNestingLevel;
$logger = $this->_config->getSQLLogger();
if ($this->transactionNestingLevel === 1) {
if ($logger) {
$logger->startQuery('"START TRANSACTION"');
}
$connection->beginTransaction();
if ($logger) {
$logger->stopQuery();
}
} elseif ($this->nestTransactionsWithSavepoints) {
if ($logger) {
$logger->startQuery('"SAVEPOINT"');
}
$this->createSavepoint($this->_getNestedTransactionSavePointName());
if ($logger) {
$logger->stopQuery();
}
}
return true;
}