/** * update database with the new owners * * @param array $owners * @throws \Exception */ private function updateOwners($owners) { $this->connection->beginTransaction(); try { foreach ($owners as $id => $owner) { $query = $this->connection->getQueryBuilder(); $query->update($this->table)->set('parent', $query->createNamedParameter(null))->set('uid_owner', $query->createNamedParameter($owner['owner']))->set('uid_initiator', $query->createNamedParameter($owner['initiator']))->where($query->expr()->eq('id', $query->createNamedParameter($id)))->execute(); } $this->connection->commit(); } catch (\Exception $e) { $this->connection->rollBack(); throw $e; } }
private function migrate(LegacyStoragesService $legacyService, StoragesService $storageService) { $existingStorage = $legacyService->getAllStorages(); $this->connection->beginTransaction(); try { foreach ($existingStorage as $storage) { $storageService->addStorage($storage); } $this->connection->commit(); } catch (\Exception $e) { $this->logger->logException($e); $this->connection->rollBack(); } }
private function migrate(LegacyStoragesService $legacyService, StoragesService $storageService) { $existingStorage = $legacyService->getAllStorages(); $this->connection->beginTransaction(); try { foreach ($existingStorage as $storage) { $mountOptions = $storage->getMountOptions(); if (!empty($mountOptions) && !isset($mountOptions['enable_sharing'])) { // existing mounts must have sharing enabled by default to avoid surprises $mountOptions['enable_sharing'] = true; $storage->setMountOptions($mountOptions); } $storageService->addStorage($storage); } $this->connection->commit(); } catch (\Exception $e) { $this->logger->logException($e); $this->connection->rollBack(); } }
/** * Rollback the database changes done during a transaction that is in progress */ public function rollBack() { $this->connection->rollBack(); }