/** * Execute and get the traversal result * * @return array $responseArray */ public function getResult() { $bodyParams = $this->attributes; $response = $this->_connection->post(Urls::URL_TRAVERSAL, $this->getConnection()->json_encode_wrapper($bodyParams)); $responseArray = $response->getJson(); return $responseArray; }
/** * creates a database * * This creates a new database<br> * * @param Connection $connection - the connection to be used * @param string $name - the database specification, for example 'myDatabase' * * @link http://www.arangodb.com/manuals/1.4/HttpDatabase.html * * @return array $responseArray - The response array. */ public static function create(Connection $connection, $name) { $payload = array(self::ENTRY_DATABASE_NAME => $name); $response = $connection->post(Urls::URL_DATABASE, $connection->json_encode_wrapper($payload)); $responseArray = $response->getJson(); return $responseArray; }
/** * Execute the transaction * * This will post the query to the server and return the results as * a Cursor. The cursor can then be used to iterate the results. * * @throws Exception throw exception if transaction failed * @return mixed true if successful without a return value or the return value if one was set in the action */ public function execute() { $response = $this->_connection->post(Urls::URL_TRANSACTION, $this->getConnection()->json_encode_wrapper($this->attributes)); $responseArray = $response->getJson(); if (isset($responseArray['result'])) { return $responseArray['result']; } return true; }
/** * Registers the user function * * If no parameters ($name,$code) are passed, it will use the properties of the object. * * If $name and/or $code are passed, it will override the object's properties with the passed ones * * @param null $name * @param null $code * * @throws Exception throws exception if registration failed * * @return mixed true if registration was successful. */ public function register($name = null, $code = null) { $attributes = $this->attributes; if ($name) { $attributes['name'] = $name; } if ($code) { $attributes['code'] = $code; } $response = $this->_connection->post(Urls::URL_AQL_USER_FUNCTION, $this->getConnection()->json_encode_wrapper($attributes)); $responseArray = $response->getJson(); return $responseArray; }
/** * Execute the export * * This will return the results as a Cursor. The cursor can then be used to iterate the results. * * @throws Exception * @return ExportCursor */ public function execute() { $data = array(self::ENTRY_FLUSH => $this->_flush, self::ENTRY_COUNT => true); if ($this->_batchSize > 0) { $data[self::ENTRY_BATCHSIZE] = $this->_batchSize; } if ($this->_limit > 0) { $data[self::ENTRY_LIMIT] = $this->_limit; } if (is_array($this->_restrictions)) { $data[self::ENTRY_RESTRICT] = $this->_restrictions; } $collection = $this->_collection; if ($collection instanceof Collection) { $collection = $collection->getName(); } $url = UrlHelper::appendParamsUrl(Urls::URL_EXPORT, array("collection" => $collection)); $response = $this->_connection->post($url, $this->getConnection()->json_encode_wrapper($data)); return new ExportCursor($this->_connection, $response->getJson(), $this->getCursorOptions()); }
/** * Processes this batch. This sends the captured requests to the server as one batch. * * @throws ClientException * @return bool - true if processing of the batch was or the HttpResponse object in case of a failure. A successful process just means that tha parts were processed. Each part has it's own response though and should be checked on its own. */ public function process() { $this->stopCapture(); $this->setBatchRequest(true); $data = ''; $batchParts = $this->getBatchParts(); if (count($batchParts) == 0) { throw new ClientException('Can\'t process empty batch.'); } /** @var $partValue BatchPart */ foreach ($batchParts as $partValue) { $data .= '--' . HttpHelper::MIME_BOUNDARY . HttpHelper::EOL; $data .= 'Content-Type: application/x-arango-batchpart' . HttpHelper::EOL; if (!is_null($partValue->getId())) { $data .= 'Content-Id: ' . (string) $partValue->getId() . HttpHelper::EOL . HttpHelper::EOL; } else { $data .= HttpHelper::EOL; } $data .= (string) $partValue->getRequest() . HttpHelper::EOL; } $data .= '--' . HttpHelper::MIME_BOUNDARY . '--' . HttpHelper::EOL . HttpHelper::EOL; $params = array(); $url = UrlHelper::appendParamsUrl(Urls::URL_BATCH, $params); $this->_batchResponse = $this->_connection->post($url, $data); if ($this->_batchResponse->getHttpCode() !== 200) { return $this->_batchResponse; } $body = $this->_batchResponse->getBody(); $body = trim($body, '--' . HttpHelper::MIME_BOUNDARY . '--'); $batchParts = $this->splitWithContentIdKey('--' . HttpHelper::MIME_BOUNDARY . HttpHelper::EOL, $body); foreach ($batchParts as $partKey => $partValue) { $response = new HttpResponse($partValue); $body = $response->getBody(); $response = new HttpResponse($body); $batchPartResponses[$partKey] = $response; $this->getPart($partKey)->setResponse($batchPartResponses[$partKey]); } return $this; }
/** * modifies an endpoint * * This will modify an existing or create a new endpoint. * * @param Connection $connection - the connection to be used * @param string $endpoint - the endpoint specification, e.g. tcp://127.0.0.1:8530 * @param array $databases - a list of database names the endpoint is responsible for. * * @link http://www.arangodb.com/manuals/1.4/HttpEndpoint.html * @return array $responseArray - The response array. */ public static function modify(Connection $connection, $endpoint, array $databases) { $payload = array(self::ENTRY_ENDPOINT => $endpoint, self::ENTRY_DATABASES => $databases); $response = $connection->post(Urls::URL_ENDPOINT, $connection->json_encode_wrapper($payload)); $responseArray = $response->getJson(); return $responseArray; }
/** * Validates the statement * * This will post the query to the server for validation and return the validation result as an array. * * @throws Exception * @return Array */ public function validate() { $data = $this->buildData(); $response = $this->_connection->post(Urls::URL_QUERY, $this->getConnection()->json_encode_wrapper($data)); return $response->getJson(); }