Пример #1
0
 /**
  * Remove a edge from a graph, identified by the graph name and edge id<br><br>
  *
  * @throws Exception
  *
  * @param mixed  $graph     - graph name as a string or instance of Graph
  * @param mixed  $edgeId    - edge id as string or number
  * @param mixed  $revision  - optional revision of the edge to be deleted
  * @param mixed  $options  optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)
  * <p>
  * <li><b>policy</b> - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li>
  * <li><b>waitForSync</b> - can be used to force synchronisation of the document removal operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li>
  * </p>
  * @param string $collection  - if one uses a graph with more than one vertex collection one must provide the collection                          
  *
  * @return bool - always true, will throw if there is an error
  * @since 1.2
  */
 public function removeEdge($graph, $edgeId, $revision = null, $options = array(), $collection = null)
 {
     if ($graph instanceof Graph) {
         $graph = $graph->getKey();
     }
     $parts = explode("/", $edgeId);
     if (count($parts) === 2) {
         $edgeId = $parts[1];
         $collection = $parts[0];
     }
     if (count($this->getEdgeCollections($graph)) !== 1 && $collection === null) {
         throw new ClientException('A collection must be provided.');
     } else {
         if (count($this->getEdgeCollections($graph)) === 1 && $collection === null) {
             $collection = $this->getEdgeCollections($graph);
             $collection = $collection[0];
         }
     }
     // This preserves compatibility for the old policy parameter.
     $params = array();
     $params = $this->validateAndIncludeOldSingleParameterInParams($options, $params, ConnectionOptions::OPTION_DELETE_POLICY);
     $params = $this->includeOptionsInParams($options, $params, array('waitForSync' => $this->getConnectionOption(ConnectionOptions::OPTION_WAIT_SYNC), 'keepNull' => true));
     if (!is_null($revision)) {
         $params[ConnectionOptions::OPTION_REVISION] = $revision;
     }
     $url = UrlHelper::buildUrl(Urls::URL_GRAPH, array($graph, Urls::URLPART_EDGE, $collection, $edgeId));
     $url = UrlHelper::appendParamsUrl($url, $params);
     $this->getConnection()->delete($url);
     return true;
 }
Пример #2
0
 /**
  * Deletes an endpoint
  *
  * This will delete an existing endpoint.
  *
  * @param Connection $connection - the connection to be used
  * @param string     $endpoint   - the endpoint specification, e.g. tcp://127.0.0.1:8530
  *
  * @link                         http://www.arangodb.com/manuals/1.4/HttpEndpoint.html
  * @return array $responseArray - The response array.
  */
 public static function delete(Connection $connection, $endpoint)
 {
     $url = UrlHelper::buildUrl(Urls::URL_ENDPOINT, array($endpoint));
     $response = $connection->delete($url);
     $responseArray = $response->getJson();
     return $responseArray;
 }
 /**
  * Retrieves information about the current database
  *
  * This will get information about the currently used database from the server
  *
  * @param Connection $connection - the connection to be used
  *
  * @link http://www.arangodb.com/manuals/1.4/HttpDatabase.html
  *
  * @return array $responseArray - The response array.
  */
 public static function getInfo(Connection $connection)
 {
     $url = UrlHelper::buildUrl(Urls::URL_DATABASE, array('current'));
     $response = $connection->get($url);
     $responseArray = $response->getJson();
     return $responseArray;
 }
 /**
  * Get registered user functions
  *
  * The method can optionally be passed a $namespace parameter to narrow the results down to a specific namespace.
  *
  * @param null $namespace
  *
  * @throws Exception throw exception if the request failed
  *
  * @return mixed true if successful without a return value or the return value if one was set in the action
  */
 public function getRegisteredUserFunctions($namespace = null)
 {
     $url = UrlHelper::buildUrl(Urls::URL_AQL_USER_FUNCTION, array());
     if (!is_null($namespace)) {
         $url = UrlHelper::appendParamsUrl($url, array('namespace' => $namespace));
     }
     $response = $this->_connection->get($url);
     $responseArray = $response->getJson();
     return $responseArray;
 }
 /**
  * Get list of all available collections per default with the collection names as index.
  * Returns empty array if none are available.
  *
  * @param array $options            - optional - an array of options.
  *                                  <p>Options are :<br>
  *                                  <li>'excludeSystem' -   With a value of true, all system collections will be excluded from the response.</li>
  *                                  <li>'keys' -  With a value of "collections", the index of the resulting array is numerical,
  *                                  With a value of "names", the index of the resulting array are the collection names.</li>
  *                                  </p>
  *
  * @return array
  */
 public function getAllCollections($options = array())
 {
     $options = array_merge(array("excludeSystem" => false, 'keys' => "names"), $options);
     $params = array();
     if ($options["excludeSystem"] === true) {
         $params[self::OPTION_EXCLUDE_SYSTEM] = true;
     }
     $url = UrlHelper::appendParamsUrl(Urls::URL_COLLECTION, $params);
     $response = $this->getConnection()->get(UrlHelper::buildUrl($url, array()));
     $response = $response->getJson();
     if (isset($options["keys"]) && isset($response[$options["keys"]])) {
         return $response[$options["keys"]];
     }
     return $response;
 }
 /**
  * Remove a user, identified by the username
  *
  * @throws Exception
  *
  * @param mixed $username - username as a string, of the user that is to be deleted
  *
  * @return bool - always true, will throw if there is an error
  */
 public function removeUser($username)
 {
     // This preserves compatibility for the old policy parameter.
     $params = array();
     $url = UrlHelper::buildUrl(Urls::URL_USER, array($username));
     $url = UrlHelper::appendParamsUrl($url, $params);
     $this->getConnection()->delete($url);
     return true;
 }
 /**
  * Remove a document from a collection (internal method)
  *
  * @throws Exception
  *
  * @param string $url          - the server-side URL being called
  * @param string $collectionId - collection id as string or number
  * @param mixed  $documentId   - document id as string or number
  * @param mixed $revision      - optional revision of the document to be deleted
  * @param mixed  $options      - optional, array of options (see below) or the boolean value for $policy (for compatibility prior to version 1.1 of this method)
  *                             <p>Options are :
  *                             <li>'policy' - update policy to be used in case of conflict ('error', 'last' or NULL [use default])</li>
  *                             <li>'waitForSync' - can be used to force synchronisation of the document removal operation to disk even in case that the waitForSync flag had been disabled for the entire collection</li>
  *                             </p>
  *
  * @return bool - always true, will throw if there is an error
  */
 protected function erase($url, $collectionId, $documentId, $revision = null, $options = array())
 {
     // This preserves compatibility for the old policy parameter.
     $params = array();
     $params = $this->validateAndIncludeOldSingleParameterInParams($options, $params, ConnectionOptions::OPTION_DELETE_POLICY);
     $params = $this->includeOptionsInParams($options, $params, array('waitForSync' => ConnectionOptions::OPTION_WAIT_SYNC));
     if (!is_null($revision)) {
         $params[ConnectionOptions::OPTION_REVISION] = $revision;
     }
     $url = UrlHelper::buildUrl($url, array($collectionId, $documentId));
     $url = UrlHelper::appendParamsUrl($url, $params);
     $this->getConnection()->delete($url);
     return true;
 }
 /**
  * Kills a specific query
  *
  * This will send an HTTP DELETE command to the server to terminate the specified query
  *
  * @param string $id - query id
  *
  * @throws Exception
  *
  * @return bool
  */
 public function kill($id)
 {
     $url = UrlHelper::buildUrl(Urls::URL_QUERY, array($id));
     $this->_connection->delete($url);
     return true;
 }