当前位置: 首页>>代码示例>>PHP>>正文


PHP Storage::adjustStorageId方法代码示例

本文整理汇总了PHP中OC\Files\Cache\Storage::adjustStorageId方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::adjustStorageId方法的具体用法?PHP Storage::adjustStorageId怎么用?PHP Storage::adjustStorageId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC\Files\Cache\Storage的用法示例。


在下文中一共展示了Storage::adjustStorageId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createStorage

 /**
  * Create a storage entry
  *
  * @param string $storageId
  * @return int
  */
 private function createStorage($storageId)
 {
     $sql = 'INSERT INTO `*PREFIX*storages` (`id`)' . ' VALUES (?)';
     $storageId = Storage::adjustStorageId($storageId);
     $numRows = $this->connection->executeUpdate($sql, array($storageId));
     $this->assertEquals(1, $numRows);
     return \OC_DB::insertid('*PREFIX*storages');
 }
开发者ID:evanjt,项目名称:core,代码行数:14,代码来源:repairlegacystorage.php

示例2: createStorage

 /**
  * Create a storage entry
  *
  * @param string $storageId
  * @return int
  */
 private function createStorage($storageId)
 {
     $sql = 'INSERT INTO `*PREFIX*storages` (`id`)' . ' VALUES (?)';
     $storageId = Storage::adjustStorageId($storageId);
     $numRows = $this->connection->executeUpdate($sql, array($storageId));
     $this->assertEquals(1, $numRows);
     return \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*storages');
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:14,代码来源:repairlegacystorage.php

示例3: fixLegacyStorage

 /**
  * Fix the given legacy storage by renaming the old id
  * to the new id. If the new id already exists, whichever
  * storage that has data in the file cache will be used.
  * If both have data, nothing will be done and false is
  * returned.
  *
  * @param string $oldId old storage id
  * @param int $oldNumericId old storage numeric id
  * @param string $userId
  * @return bool true if fixed, false otherwise
  * @throws RepairException
  */
 private function fixLegacyStorage($oldId, $oldNumericId, $userId = null)
 {
     // check whether the new storage already exists
     if (is_null($userId)) {
         $userId = $this->extractUserId($oldId);
     }
     $newId = 'home::' . $userId;
     // check if target id already exists
     $newNumericId = Storage::getNumericStorageId($newId);
     if (!is_null($newNumericId)) {
         $newNumericId = (int) $newNumericId;
         // try and resolve the conflict
         // check which one of "local::" or "home::" needs to be kept
         $this->findStorageInCacheStatement->execute(array($oldNumericId, $newNumericId));
         $row1 = $this->findStorageInCacheStatement->fetch();
         $row2 = $this->findStorageInCacheStatement->fetch();
         $this->findStorageInCacheStatement->closeCursor();
         if ($row2 !== false) {
             // two results means both storages have data, not auto-fixable
             throw new RepairException('Could not automatically fix legacy storage ' . '"' . $oldId . '" => "' . $newId . '"' . ' because they both have data.');
         }
         if ($row1 === false || (int) $row1['storage'] === $oldNumericId) {
             // old storage has data, then delete the empty new id
             $toDelete = $newId;
         } else {
             if ((int) $row1['storage'] === $newNumericId) {
                 // new storage has data, then delete the empty old id
                 $toDelete = $oldId;
             } else {
                 // unknown case, do not continue
                 return false;
             }
         }
         // delete storage including file cache
         Storage::remove($toDelete);
         // if we deleted the old id, the new id will be used
         // automatically
         if ($toDelete === $oldId) {
             // nothing more to do
             return true;
         }
     }
     // rename old id to new id
     $newId = Storage::adjustStorageId($newId);
     $oldId = Storage::adjustStorageId($oldId);
     $rowCount = $this->renameStorageStatement->execute(array($newId, $oldId));
     $this->renameStorageStatement->closeCursor();
     return $rowCount === 1;
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:62,代码来源:RepairLegacyStorages.php


注:本文中的OC\Files\Cache\Storage::adjustStorageId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。