當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UrlHelper::getDocumentIdFromLocation方法代碼示例

本文整理匯總了PHP中UrlHelper::getDocumentIdFromLocation方法的典型用法代碼示例。如果您正苦於以下問題:PHP UrlHelper::getDocumentIdFromLocation方法的具體用法?PHP UrlHelper::getDocumentIdFromLocation怎麽用?PHP UrlHelper::getDocumentIdFromLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UrlHelper的用法示例。


在下文中一共展示了UrlHelper::getDocumentIdFromLocation方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: save

 /**
  * save a document to a collection
  *
  * This will add the document to the collection and return the document's id
  *
  * This will throw if the document cannot be saved
  *
  * @throws Exception
  *
  * @param mixed      $collectionId - collection id as string or number
  * @param mixed      $document     - the document to be added, can be passed as a document or an array
  * @param bool|array $options      - optional, prior to v1.2.0 this was a boolean value for create. Since v1.0.0 it's an array of options.
  *                                 <p>Options are :<br>
  *                                 <li>'create' - create the collection if it does not yet exist.</li>
  *                                 <li>'waitForSync' -  if set to true, then all removal operations will instantly be synchronised to disk / If this is not specified, then the collection's default sync behavior will be applied.</li>
  *                                 </p>
  *
  * @return mixed - id of document created
  * @since 1.0
  */
 public function save($collectionId, $document, $options = array())
 {
     // This preserves compatibility for the old create parameter.
     $params = array(self::OPTION_COLLECTION => $collectionId);
     $params = $this->validateAndIncludeOldSingleParameterInParams($options, $params, ConnectionOptions::OPTION_CREATE);
     $params = $this->includeOptionsInParams($options, $params, array(ConnectionOptions::OPTION_WAIT_SYNC => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC)));
     if (is_array($document)) {
         $document = Document::createFromArray($document);
     }
     $data = $document->getAll();
     $url = UrlHelper::appendParamsUrl(Urls::URL_DOCUMENT, $params);
     $response = $this->getConnection()->post($url, $this->json_encode_wrapper($data));
     $location = $response->getLocationHeader();
     if (!$location) {
         throw new ClientException('Did not find location header in server response');
     }
     $json = $response->getJson();
     $id = UrlHelper::getDocumentIdFromLocation($location);
     $document->setInternalId($json[Document::ENTRY_ID]);
     $document->setRevision($json[Document::ENTRY_REV]);
     if ($id != $document->getId()) {
         throw new ClientException('Got an invalid response from the server');
     }
     $document->setIsNew(false);
     return $document->getId();
 }
開發者ID:TomSearch,項目名稱:arangodb-php-docs,代碼行數:46,代碼來源:DocumentHandler.php

示例2: getAllIds

 /**
  * Get the list of all documents' ids from a collection
  *
  * This will throw if the list cannot be fetched from the server
  *
  * @throws Exception
  *
  * @param mixed $collectionId - collection id as string or number
  *
  * @return array - ids of documents in the collection
  */
 public function getAllIds($collectionId)
 {
     $url = UrlHelper::appendParamsUrl(Urls::URL_DOCUMENT, array(self::OPTION_COLLECTION => $collectionId));
     $response = $this->getConnection()->get($url);
     $data = $response->getJson();
     if (!isset($data[self::ENTRY_DOCUMENTS])) {
         throw new ClientException('Got an invalid document list from the server');
     }
     $ids = array();
     foreach ($data[self::ENTRY_DOCUMENTS] as $location) {
         $ids[] = UrlHelper::getDocumentIdFromLocation($location);
     }
     return $ids;
 }
開發者ID:TomSearch,項目名稱:arangodb-php-docs,代碼行數:25,代碼來源:CollectionHandler.php

示例3: saveEdge

 /**
  * save an edge to an edge-collection
  *
  * This will save the edge to the collection and return the edges-document's id
  *
  * This will throw if the document cannot be saved
  *
  * @throws Exception
  *
  * @param mixed      $collectionId - collection id as string or number
  * @param mixed      $from         - from vertex
  * @param mixed      $to           - to vertex
  * @param mixed      $document     - the edge-document to be added, can be passed as an object or an array
  * @param bool|array $options      - optional, prior to v1.2.0 this was a boolean value for create. Since v1.0.0 it's an array of options.
  *                                 <p>Options are :<br>
  *                                 <li>'create' - create the collection if it does not yet exist.</li>
  *                                 <li>'waitForSync' -  if set to true, then all removal operations will instantly be synchronised to disk.<br>
  *                                 If this is not specified, then the collection's default sync behavior will be applied.</li>
  *                                 </p>
  *
  * @return mixed - id of document created
  * @since 1.0
  */
 public function saveEdge($collectionId, $from, $to, $document, $options = array())
 {
     if ($collectionId instanceof Collection) {
         $collectionId = $collectionId->getName();
     }
     if (is_array($document)) {
         $document = Edge::createFromArray($document);
     }
     $document->setFrom($from);
     $document->setTo($to);
     $params = array(self::OPTION_COLLECTION => $collectionId, self::OPTION_FROM => $document->getFrom(), self::OPTION_TO => $document->getTo());
     $params = $this->validateAndIncludeOldSingleParameterInParams($options, $params, ConnectionOptions::OPTION_CREATE);
     $params = $this->includeOptionsInParams($options, $params, array(ConnectionOptions::OPTION_WAIT_SYNC => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC)));
     $data = $document->getAll();
     $url = UrlHelper::appendParamsUrl(Urls::URL_EDGE, $params);
     $response = $this->getConnection()->post($url, $this->json_encode_wrapper($data));
     $location = $response->getLocationHeader();
     if (!$location) {
         throw new ClientException('Did not find location header in server response');
     }
     $json = $response->getJson();
     $id = UrlHelper::getDocumentIdFromLocation($location);
     $document->setInternalId($json[Edge::ENTRY_ID]);
     $document->setRevision($json[Edge::ENTRY_REV]);
     if ($id != $document->getId()) {
         throw new ClientException('Got an invalid response from the server');
     }
     $document->setIsNew(false);
     return $document->getId();
 }
開發者ID:vinigomescunha,項目名稱:ArangoDB-Ajax-PHP-Example,代碼行數:53,代碼來源:EdgeHandler.php


注:本文中的UrlHelper::getDocumentIdFromLocation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。