Example #1
0
 /**
  * Fetch single document by ID
  *
  * @param  string $collectionName Collection name
  * @param  mixed $documentId Document ID, adapter-dependent
  * @param  array $options
  * @return \ZendCloud\DocumentService\Document
  */
 public function fetchDocument($collectionName, $documentId, $options = null)
 {
     $documentId = $this->_validateDocumentId($documentId, $collectionName);
     try {
         $entity = $this->_storageClient->retrieveEntityById($collectionName, $documentId[0], $documentId[1]);
         $documentClass = $this->getDocumentClass();
         return new $documentClass($this->_resolveAttributes($entity), array($entity->getPartitionKey(), $entity->getRowKey()));
     } catch (WindowsAzureException\ExceptionInterface $e) {
         if (strpos($e->getMessage(), "does not exist") !== false) {
             return false;
         }
         throw new Exception\RuntimeException('Error on document fetch: ' . $e->getMessage(), $e->getCode(), $e);
     }
 }