public function persist(PackageVersion $packageVersion) { if (null === ($packageVersionId = $packageVersion->getId())) { throw new \InvalidArgumentException('The $packageVersion must already have been persisted to the database.'); } // We are ensuring that all inserts are executed within a transaction. // See: http://dev.mysql.com/doc/refman/5.5/en/optimizing-innodb-bulk-data-loading.html $this->con->beginTransaction(); try { foreach ($packageVersion->getContainers() as $container) { $this->containerPersister->persist($container, $packageVersionId); } foreach ($packageVersion->getFunctions() as $function) { $this->functionPersister->persist($function, $packageVersionId); } foreach ($packageVersion->getConstants() as $constant) { $this->constantPersister->persist($constant, $packageVersionId); } $this->con->commit(); } catch (\Exception $ex) { $this->con->rollBack(); throw $ex; } }