本文整理汇总了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();
}