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