本文整理匯總了PHP中OCP\IDBConnection::rollBack方法的典型用法代碼示例。如果您正苦於以下問題:PHP IDBConnection::rollBack方法的具體用法?PHP IDBConnection::rollBack怎麽用?PHP IDBConnection::rollBack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OCP\IDBConnection
的用法示例。
在下文中一共展示了IDBConnection::rollBack方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: updateOwners
/**
* 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;
}
}
示例2: migrate
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();
}
}
示例3: migrate
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();
}
}
示例4: rollBack
/**
* Rollback the database changes done during a transaction that is in progress
*/
public function rollBack()
{
$this->connection->rollBack();
}